mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-03 16:56:54 +00:00
26 lines
584 B
Perl
Executable File
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;
|