2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 18:59:33 +00:00

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:
tobiasfaust 2013-03-05 19:14:41 +00:00
parent 6327a552fe
commit 2a02d6fc82

View File

@ -396,6 +396,15 @@ DbLog_Connect($)
Log 3, "Connection to db $dbconn established";
$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;
}