From 76c676fdec660d52b2d46d061838e555c239cba5 Mon Sep 17 00:00:00 2001 From: auxlife Date: Wed, 29 Nov 2017 14:07:55 -0800 Subject: [PATCH] Create dbloadfromsqlite.php --- dbloadfromsqlite.php | 58 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 dbloadfromsqlite.php diff --git a/dbloadfromsqlite.php b/dbloadfromsqlite.php new file mode 100644 index 0000000..a77d9c6 --- /dev/null +++ b/dbloadfromsqlite.php @@ -0,0 +1,58 @@ +open('xdrip.sqlite'); + } + } + $db = new MyDB(); + if(!$db){ + echo $db->lastErrorMsg(); + } else { + echo "Opened database successfully

\n\n"; + } + ConnectDB(); + $OldTimeStamp = GetLastTimeStamp(); + $sql ="SELECT * from Calibration Where Timestamp > ".$OldTimeStamp." Order by Timestamp DESC;"; + + $ret = $db->query($sql); + while($row = $ret->fetchArray(SQLITE3_ASSOC) ){ + echo InsertValue(GetDeviceTimeFromMU($row['timestamp']), "mbg", $row['bg'] , '"payload":{"subType":"manual","time":"'.GetDeviceTimeFromMU($row['timestamp']).'","timezoneOffset":'.GetUtcOffset().',"type":"smbg","units":"mmol/L","value":'.ConvertToMmol($row['bg']).'}',$row['timestamp']); + + } + + $sql ="SELECT * from BgReadings Where Timestamp > ".$OldTimeStamp." Order by Timestamp DESC;"; + + $ret = $db->query($sql); + while($row = $ret->fetchArray(SQLITE3_ASSOC) ){ + echo InsertValue(GetDeviceTimeFromMU($row['timestamp']), "sgv", round($row['calculated_value']) , '"payload":{"internalTime":"'.GetDeviceTimeFromMU($row['timestamp']).'","value":'.ConvertToMmol(round($row['calculated_value'])).'}',$row['timestamp']); + + } + $cronjob = fopen("c:\\xampp\\htdocs\\drip\\cronjob.bat","w"); + fwrite($cronjob, "c:\\xampp\\php\\php.exe c:\\xampp\\htdocs\\drip\\dbupload.cli.php". PHP_EOL); + fwrite($cronjob, "exit"); + fclose($cronjob); + + +DisconnectDB(); + $db->close(); +?>