2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-03 16:56:54 +00:00
betateilchen f1f6e56362 maintainDB.cgi: add maintenance script
git-svn-id: https://svn.fhem.de/fhem/trunk@14770 2b470e98-0d58-463d-a4d8-8e2adae1ed80
2017-07-23 09:34:01 +00:00

26 lines
584 B
Perl
Executable File

#!/usr/bin/perl -w
# $Id$
use strict;
use warnings;
use DBI;
my $limit = "datetime('now', '-13 months')";
# directory cointains databases
my $datadir = "./data";
my $dbf = "$datadir/fhem_statistics_2017.sqlite";
my $dsn = "dbi:SQLite:dbname=$dbf";
my $sth;
my $dbh = DBI->connect($dsn,"","", { RaiseError => 1, ShowErrorStatement => 1 }) ||
die "Cannot connect: $DBI::errstr";
print "Deleting records...\n";
$dbh->do("DELETE FROM jsonNodes where lastSeen < $limit");
print "VACUUM...\n";
$dbh->do("VACUUM");
$dbh->disconnect();
print "Done.\n";
1;