mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-04 11:26:55 +00:00
26 lines
584 B
Plaintext
26 lines
584 B
Plaintext
![]() |
#!/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;
|