Hello,
First let me answer your questions:
- INSERT, SELECT - works properly just DELETE command doesn't work
- Raspberry Pi OS Lite
- no Docker
- All instances are Read-Write-Create
Here is a simplify flow including just the SQlite nodes, I add the insert node as my original flow gets the insert from Modbus.
Interesting is that in this flow the DELETE commands works .
I have to check why in my original flow same DELETE syntax doesn't perform (no errors).
thanks for your help.
[{"id":"6603ad1a.d86384","type":"sqlite","z":"9d6ab3c7.985c","mydb":"10fc33a3.4b18bc","sqlquery":"msg.topic","sql":"","name":"test Log","x":480,"y":1380,"wires":[["41292ce7.18f4dc"]]},{"id":"6d41f9d.fdf1288","type":"inject","z":"9d6ab3c7.985c","name":"create database","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":"","topic":"CREATE TABLE 'alarmlog' ('id' INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, 'Time' TEXT, 'Channel' TEXT, 'Alarm' TEXT, 'Status' TEXT, 'epoch' INTEGER, 'timestamp' INTEGER DEFAULT CURRENT_TIMESTAMP)","payload":"","payloadType":"date","x":300,"y":1380,"wires":[["6603ad1a.d86384"]]},{"id":"aedde1d9.afd5c","type":"ui_button","z":"9d6ab3c7.985c","name":"","group":"2787f0f5.7d5fa8","order":5,"width":3,"height":1,"passthru":true,"label":"Last 5 min Alarms ","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"date","topic":"SELECT * FROM alarmlog WHERE datetime(timestamp, 'localtime') > datetime('now', 'localtime', '-5 minutes') ORDER BY timestamp DESC","topicType":"str","x":750,"y":1620,"wires":[["d34ad534.c1a18"]]},{"id":"d34ad534.c1a18","type":"delay","z":"9d6ab3c7.985c","name":"","pauseType":"delay","timeout":"500","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":950,"y":1620,"wires":[["6ab078f3.02beb"]]},{"id":"bc54c55.612c9b8","type":"ui_template","z":"9d6ab3c7.985c","group":"2787f0f5.7d5fa8","name":"Alarm Log2","order":2,"width":12,"height":4,"format":"\n<style>\ntable\n{\n font-size: 13px;\n color: white;\n width: 100%;\n border: 1px color #000; \n}\n.main\n{\n border: 1px color #000; \n width: 100%;\n height:100px;\n}\n\n .mytable2 td, .mytable2 th { width:21%;background:darkred; }\n .mytable2 td + td, .mytable2 th + th { width:11%; }\n .mytable2 td + td + td, .mytable2 th + th + th { width:52%; }\n .mytable2 td + td + td + td, .mytable2 th + th + th + td { width:16%; }\n</style>\n<!--\n<div style='background-color: red; width:100%; color:white'></div>\n<div ng-bind-html=\"msg.payload\"></div>\n-->\n\n<div ng-bind-html=\"msg.payload\" height=\"300\" style=\"height: 250px;\"></div>\n","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"local","x":1510,"y":1560,"wires":[[]]},{"id":"6ab078f3.02beb","type":"sqlite","z":"9d6ab3c7.985c","mydb":"10fc33a3.4b18bc","sqlquery":"msg.topic","sql":"","name":"test Log","x":1160,"y":1560,"wires":[["b1df61a.aff072","2118aa.0795d756"]]},{"id":"b1df61a.aff072","type":"template","z":"9d6ab3c7.985c","name":"Format","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"\n<table>\n \n {{#payload}}\n <tr class=\"mytable2\">\n <td><center>{{Time}}</td>\n <td><center>{{Channel}}</td>\n <td><center>{{Alarm}}</td>\n <td><center>{{Status}}</td>\n </tr>\n {{/payload}}\n</table>\n","output":"str","x":1340,"y":1560,"wires":[["bc54c55.612c9b8"]]},{"id":"1bdfe7e2.998e38","type":"ui_template","z":"9d6ab3c7.985c","group":"2787f0f5.7d5fa8","name":"Alarm Log menu2","order":1,"width":0,"height":0,"format":"\n<style>\ntable\n{\n font-size: 204px;\n color: white;\n width: 100%;\n border: 1px color #000;\n margin: 10px 0px 0px 0px;\n\n}\n.main\n{\n border: 1px color #000; \n width: 100%;\n\n}\n\n .mytable td, .mytable th { width:21%;}\n .mytable td + td, .mytable th + th { width:11%; }\n .mytable td + td + td, .mytable th + th + th { width:52%; }\n .mytable td + td + td + td, .mytable th + th + th + td { width:16%;}\n\n</style>\n<!--\n<div style='background-color: red; width:100%; color:white'></div>\n<div ng-bind-html=\"msg.payload\"></div>\n-->\n\n<div ng-bind-html=\"msg.payload\" height=\"0\" style=\"height: 0px;\"></div>\n","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"local","x":1530,"y":1520,"wires":[[]]},{"id":"2118aa.0795d756","type":"template","z":"9d6ab3c7.985c","name":"Format","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<table class=\"mytable\" border=\"1\">\n\n <tr>\n\n <th>Time</th>\n <th>Channel</th>\n <th>Alarm Message</th>\n <th>Status</th>\n\n </tr>\n</table>\n\n\n","output":"str","x":1340,"y":1520,"wires":[["1bdfe7e2.998e38"]]},{"id":"ea2ec7ff.4837a8","type":"inject","z":"9d6ab3c7.985c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":"","topic":"","payload":"","payloadType":"date","x":570,"y":1560,"wires":[["8f2d453e.1844c8"]]},{"id":"8f2d453e.1844c8","type":"delay","z":"9d6ab3c7.985c","name":"","pauseType":"delay","timeout":"500","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":750,"y":1560,"wires":[["a3ff11c0.9e5e38"]]},{"id":"a3ff11c0.9e5e38","type":"change","z":"9d6ab3c7.985c","name":"Last 10 events","rules":[{"t":"set","p":"topic","pt":"msg","to":"SELECT * FROM alarmlog ORDER BY timestamp DESC LIMIT 10","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":920,"y":1560,"wires":[["6ab078f3.02beb"]]},{"id":"e08024b0.813de","type":"sqlite","z":"9d6ab3c7.985c","mydb":"10fc33a3.4b18bc","sqlquery":"msg.topic","sql":"","name":"test Log","x":620,"y":1500,"wires":[["8f2d453e.1844c8"]]},{"id":"f1e3fb3d.2c0b48","type":"function","z":"9d6ab3c7.985c","name":"","func":"var t = new Date();\nvar epoch = t.getTime();\nTime = (('00' + t.getHours()).slice(-2) + ':' + ('00' + t.getMinutes()).slice(-2) + ':' + ('00' + t.getSeconds()).slice(-2) + ' ' + ('00' + (t.getMonth() + 1)).slice(-2) + '-' + ('00' + t.getDate()).slice(-2) + '-' + (t.getYear()-100));\n\nChannelNo = \"00001\"\nAlarmlog = \"This is a test message!\";\nStatuslog = \"ALARM\"\n\nmsg.topic = \"INSERT INTO alarmlog (Time,Channel,Alarm,Status,epoch) \" + \"VALUES ('\"+Time+\"','\"+ChannelNo+\"','\"+Alarmlog+\"','\"+Statuslog+\"',\"+epoch+\")\";\nmsg.payload = {Time, ChannelNo, Alarmlog, Statuslog};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":460,"y":1500,"wires":[["e08024b0.813de"]]},{"id":"3bf0e153.dccc2e","type":"inject","z":"9d6ab3c7.985c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":"","topic":"","payload":"","payloadType":"date","x":280,"y":1440,"wires":[["f1e3fb3d.2c0b48"]]},{"id":"41292ce7.18f4dc","type":"debug","z":"9d6ab3c7.985c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":650,"y":1380,"wires":[]},{"id":"ef19e047.46f3d8","type":"change","z":"9d6ab3c7.985c","name":"All events","rules":[{"t":"set","p":"topic","pt":"msg","to":"SELECT * FROM alarmlog ORDER BY timestamp DESC","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":960,"y":1680,"wires":[["6ab078f3.02beb"]]},{"id":"6af0717b.ea8668","type":"delay","z":"9d6ab3c7.985c","name":"","pauseType":"delay","timeout":"500","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":790,"y":1680,"wires":[["ef19e047.46f3d8"]]},{"id":"c1f4d8be.ec9cb","type":"ui_button","z":"9d6ab3c7.985c","name":"","group":"2787f0f5.7d5fa8","order":4,"width":3,"height":1,"passthru":true,"label":"All Alarms","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"date","topic":"","topicType":"str","x":620,"y":1680,"wires":[["6af0717b.ea8668"]]},{"id":"a9a4a1dc.198688","type":"ui_button","z":"9d6ab3c7.985c","name":"","group":"2787f0f5.7d5fa8","order":3,"width":3,"height":1,"passthru":true,"label":"Insert record","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"date","topic":"","topicType":"str","x":270,"y":1500,"wires":[["f1e3fb3d.2c0b48"]]},{"id":"c790c843.20d448","type":"ui_button","z":"9d6ab3c7.985c","name":"","group":"2787f0f5.7d5fa8","order":6,"width":3,"height":1,"passthru":false,"label":"Delete dB > 1 min","tooltip":"","color":"","bgcolor":"orange","icon":"","payload":"","payloadType":"date","topic":"DELETE FROM alarmlog WHERE datetime(timestamp, 'localtime') < datetime('now', 'localtime', '-1 minutes')","topicType":"str","x":930,"y":1740,"wires":[["6ab078f3.02beb"]]},{"id":"10fc33a3.4b18bc","type":"sqlitedb","db":"test.db","mode":"RWC"},{"id":"2787f0f5.7d5fa8","type":"ui_group","name":"Alarms Log","tab":"f3e9af7a.6f0da","order":2,"disp":true,"width":12,"collapse":false},{"id":"f3e9af7a.6f0da","type":"ui_tab","name":"Test","icon":"dashboard","order":4,"disabled":false,"hidden":false}]