-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathsqlite-test.json
1 lines (1 loc) · 7.43 KB
/
sqlite-test.json
1
[{"id":"95f6fad4.ac8458","type":"tab","label":"SQLite 3 DB","disabled":false,"info":""},{"id":"4873331e.c041fc","type":"debug","z":"95f6fad4.ac8458","name":"","active":false,"console":"false","complete":"false","x":1230,"y":260,"wires":[]},{"id":"71aae8d7.3ea1c8","type":"sqlite","z":"95f6fad4.ac8458","mydb":"1411c18e.1b531e","sql":"","name":"test 3","x":1090,"y":260,"wires":[["4873331e.c041fc"]]},{"id":"4ddf68e8.bf8038","type":"inject","z":"95f6fad4.ac8458","name":"DELETE","topic":"DELETE FROM table1, table2","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":"","x":760,"y":200,"wires":[["71aae8d7.3ea1c8"]]},{"id":"9c6a3f40.a2d86","type":"inject","z":"95f6fad4.ac8458","name":"Insert temp hum to table 1","topic":"","payload":"{\"table\":\"table1\",\"temperature\":11.5,\"humidity\":40.5}","payloadType":"json","repeat":"5","crontab":"","once":true,"onceDelay":"2","x":240,"y":260,"wires":[["8e45a447.f61578"]]},{"id":"7a096357.feae9c","type":"inject","z":"95f6fad4.ac8458","name":"SELECT and COMPARE","topic":"SELECT table1.time, table1.temperature AS t1, table2.temperature AS t2, table1.humidity AS h1, table2.humidity AS h2, ROUND((table1.temperature-table2.temperature),2) AS deltaTemp, ROUND((table1.humidity-table2.humidity),2) AS deltaHum FROM table1, table2 WHERE ABS(table1.time-table2.time)<1000","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":"","x":250,"y":460,"wires":[["1b97f9e0.1fed16"]]},{"id":"ef80f013.d83d6","type":"inject","z":"95f6fad4.ac8458","name":"CREATE TABLE1","topic":"CREATE TABLE table1(id INTEGER PRIMARY KEY AUTOINCREMENT, time INTEGER, temperature NUMERIC, humidity NUMERIC)","payload":"","payloadType":"date","repeat":"","crontab":"","once":true,"onceDelay":"0.1","x":790,"y":100,"wires":[["71aae8d7.3ea1c8"]]},{"id":"abbdaa7c.bd29d8","type":"comment","z":"95f6fad4.ac8458","name":"CREATE TABLE table1(id INTEGER PRIMARY KEY AUTOINCREMENT, time INTEGER, temperature NUMERIC, humidity NUMERIC)","info":"","x":550,"y":60,"wires":[]},{"id":"c7a17707.707d38","type":"template","z":"95f6fad4.ac8458","name":"INSERT QUERY","field":"topic","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"INSERT into {{payload.table}} (time,temperature, humidity)\nvalues({{myepoch}},{{payload.temperature}},{{payload.humidity}})","output":"str","x":890,"y":260,"wires":[[]]},{"id":"6a26a80d.0a5fe8","type":"simpletime","z":"95f6fad4.ac8458","name":"","x":690,"y":260,"wires":[["18eeaa7c.0fc726"]]},{"id":"8e45a447.f61578","type":"change","z":"95f6fad4.ac8458","name":"","rules":[{"t":"set","p":"payload.temperature","pt":"msg","to":"msg.payload.temperature+$round($random()*20,1)","tot":"jsonata"},{"t":"set","p":"payload.humidity","pt":"msg","to":"msg.payload.humidity+$round($random()*20,1)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":480,"y":260,"wires":[["6a26a80d.0a5fe8"]]},{"id":"d9b9727b.da5ed","type":"inject","z":"95f6fad4.ac8458","name":"Insert temp hum to table 2","topic":"","payload":"{\"table\":\"table2\",\"temperature\":1.5,\"humidity\":10.5}","payloadType":"json","repeat":"5","crontab":"","once":true,"onceDelay":"2","x":240,"y":300,"wires":[["d5bccf04.aaa91"]]},{"id":"d5bccf04.aaa91","type":"change","z":"95f6fad4.ac8458","name":"","rules":[{"t":"set","p":"payload.temperature","pt":"msg","to":"msg.payload.temperature+$round($random()*20,1)","tot":"jsonata"},{"t":"set","p":"payload.humidity","pt":"msg","to":"msg.payload.humidity+$round($random()*20,1)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":480,"y":300,"wires":[["6a26a80d.0a5fe8"]]},{"id":"21b68e5c.44b392","type":"inject","z":"95f6fad4.ac8458","name":"CREATE TABLE2","topic":"CREATE TABLE table2(id INTEGER PRIMARY KEY AUTOINCREMENT, time INTEGER, temperature NUMERIC, humidity NUMERIC)","payload":"","payloadType":"date","repeat":"","crontab":"","once":true,"onceDelay":"0.2","x":790,"y":140,"wires":[["71aae8d7.3ea1c8"]]},{"id":"1b97f9e0.1fed16","type":"sqlite","z":"95f6fad4.ac8458","mydb":"1411c18e.1b531e","sql":"","name":"test 3","x":450,"y":460,"wires":[["6059c6b5.90fe78"]]},{"id":"6059c6b5.90fe78","type":"debug","z":"95f6fad4.ac8458","name":"","active":true,"console":"false","complete":"false","x":610,"y":460,"wires":[]},{"id":"94fbf1de.d6eaa","type":"debug","z":"95f6fad4.ac8458","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1110,"y":320,"wires":[]},{"id":"792bea.b654b418","type":"comment","z":"95f6fad4.ac8458","name":"Select and compare via SQLite call","info":"SELECT \n table1.time, \n table1.temperature AS t1, \n table2.temperature AS t2, \n table1.humidity AS h1, \n table2.humidity AS h2, ROUND((table1.temperature-table2.temperature),2) AS deltaTemp, ROUND((table1.humidity-table2.humidity),2) AS deltaHum \n\nFROM \n table1, \n table2 \n \nWHERE \n\n ABS(table1.time-table2.time)<1000","x":180,"y":380,"wires":[]},{"id":"1ef63d15.ca6483","type":"function","z":"95f6fad4.ac8458","name":"COMPARE FUNCTION","func":"var array = [];\nfor(var i = 0; i < msg.payload.length; i++){\n elem = msg.payload[i]\nif(Math.abs(elem.time1-elem.time2)<1000){\n array.push({\n \"time\":elem.time1,\n \"t1\":elem.t1,\n \"t2\":elem.t2,\n \"h1\":elem.h1,\n \"h2\":elem.h2,\n \"deltaTemp\":Math.round(elem.t1-elem.t2,2),\n \"deltaHum\":Math.round(elem.h1-elem.h2,2)\n })\n}\n}\nmsg.payload = array\nreturn msg;","outputs":1,"noerr":0,"x":590,"y":560,"wires":[["bd650a7.f412ef8"]]},{"id":"2eacb28d.90559e","type":"sqlite","z":"95f6fad4.ac8458","mydb":"1411c18e.1b531e","sql":"","name":"test 3","x":390,"y":620,"wires":[["1ef63d15.ca6483","3d0ded4b.3d64d2"]]},{"id":"bd650a7.f412ef8","type":"debug","z":"95f6fad4.ac8458","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":850,"y":620,"wires":[]},{"id":"18eeaa7c.0fc726","type":"function","z":"95f6fad4.ac8458","name":"INSERT FUNCTION","func":"msg.topic = \"INSERT INTO \"+msg.payload.table+\" (time,temperature,humidity) values(\"+msg.myepoch+\",\"+msg.payload.temperature+\",\"+msg.payload.humidity+\")\"\nreturn msg;","outputs":1,"noerr":0,"x":880,"y":320,"wires":[["71aae8d7.3ea1c8","94fbf1de.d6eaa"]]},{"id":"3d0ded4b.3d64d2","type":"debug","z":"95f6fad4.ac8458","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":650,"y":620,"wires":[]},{"id":"c3767158.ef71f","type":"inject","z":"95f6fad4.ac8458","name":"SELECT AND COMPARE","topic":"SELECT \ttable1.time AS time1, \ttable1.temperature AS t1, \ttable1.humidity AS h1, \ttable2.time AS time2, \ttable2.temperature AS t2, \ttable2.humidity AS h2 FROM \ttable1, table2 WHERE ABS(table1.time-table2.time)<1000","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":620,"wires":[["2eacb28d.90559e"]]},{"id":"515da492.65d13c","type":"comment","z":"95f6fad4.ac8458","name":"Select and compare via SQLite call and Function","info":"SELECT \t\n table1.time AS time1, \t\n table1.temperature AS t1, \t\n table1.humidity AS h1, \t\n table2.time AS time2, \t\n table2.temperature AS t2, \t\n table2.humidity AS h2 \n\nFROM \t\n table1, \n table2 \n \nWHERE \n \n ABS(table1.time-table2.time)<1000","x":220,"y":540,"wires":[]},{"id":"1411c18e.1b531e","type":"sqlitedb","z":"","db":"C:\\Users\\Davide Gomba\\Documents\\A - ITS\\online course\\db\\database-3.db","mode":"RWC"}]