93_DbLog.pm: Changes only for SQLite
- Moves the 'current' table to memory and modifies a few internal parameters in SQLite to minimize flash wear. - Makes easier to setup DbLog with SQLite. Database tables are created if not exists automatically when the database is opened. git-svn-id: https://svn.fhem.de/fhem/trunk@2855 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
@@ -396,6 +396,15 @@ DbLog_Connect($)
|
|||||||
Log 3, "Connection to db $dbconn established";
|
Log 3, "Connection to db $dbconn established";
|
||||||
$hash->{DBH}= $dbh;
|
$hash->{DBH}= $dbh;
|
||||||
|
|
||||||
|
if ($hash->{DBMODEL} eq "SQLITE") {
|
||||||
|
$dbh->do("PRAGMA temp_store=MEMORY");
|
||||||
|
$dbh->do("PRAGMA synchronous=NORMAL");
|
||||||
|
$dbh->do("PRAGMA journal_mode=WAL");
|
||||||
|
$dbh->do("CREATE TEMP TABLE IF NOT EXISTS current (TIMESTAMP TIMESTAMP, DEVICE varchar(32), TYPE varchar(32), EVENT varchar(512), READING varchar(32), VALUE varchar(32), UNIT varchar(32))");
|
||||||
|
$dbh->do("CREATE TABLE IF NOT EXISTS history (TIMESTAMP TIMESTAMP, DEVICE varchar(32), TYPE varchar(32), EVENT varchar(512), READING varchar(32), VALUE varchar(32), UNIT varchar(32))");
|
||||||
|
$dbh->do("CREATE INDEX IF NOT EXISTS Search_Idx ON `history` (DEVICE, READING, TIMESTAMP)");
|
||||||
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user