MariaDB Flow Sample
MariaDB sample flow. Contains a template node and a mysql node.
[{"id":"f1a8a57d.896448","type":"inject","z":"effec76.43dd238","name":"CREATE","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":160,"y":200,"wires":[["16d49f4f.2f72e1"]]},{"id":"d8886e88.2e352","type":"debug","z":"effec76.43dd238","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":690,"y":200,"wires":[]},{"id":"565b9eff.a027b","type":"inject","z":"effec76.43dd238","name":"INSERT","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":160,"y":260,"wires":[["2ac9919.fbaf86e"]]},{"id":"2ac9919.fbaf86e","type":"function","z":"effec76.43dd238","name":"INSERT","func":"if (Math.random() < 0.5) { room = 503;}else{ room = 602; }\nif (Math.random() < 0.5) { id = 9909;}else{ id = 1893; }\n\ntopic = \"INSERT INTO `test`.`access` (`room`, `id`) VALUES ('\";\ntopic = topic + room +\"', '\";\ntopic = topic + id + \"');\";\n\nmsg.topic = topic;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":340,"y":260,"wires":[["fdbcc9a.f22b838"]]},{"id":"7286764d.703128","type":"debug","z":"effec76.43dd238","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":690,"y":260,"wires":[]},{"id":"e11efb22.8739f8","type":"inject","z":"effec76.43dd238","name":"DELETE ","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":160,"y":320,"wires":[["8094763.a62db88"]]},{"id":"ee3ecafb.5dddf8","type":"debug","z":"effec76.43dd238","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":690,"y":320,"wires":[]},{"id":"c0fb919f.f6544","type":"inject","z":"effec76.43dd238","name":"UPDATE","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":160,"y":380,"wires":[["86051971.03c5c8"]]},{"id":"26081a12.74a426","type":"debug","z":"effec76.43dd238","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":690,"y":380,"wires":[]},{"id":"17cfb5e3.60ca7a","type":"inject","z":"effec76.43dd238","name":"COUNT","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":150,"y":440,"wires":[["4f194982.db8818"]]},{"id":"c1a61fe1.01abc","type":"inject","z":"effec76.43dd238","name":"SELECT","repeat":"1","crontab":"","once":false,"onceDelay":"1","topic":"","payload":"","payloadType":"date","x":160,"y":500,"wires":[["2fa7fa16.df7d36"]]},{"id":"99b466a0.219ac8","type":"ui_template","z":"effec76.43dd238","group":"eed4bf37.31aee","name":"","order":2,"width":"6","height":"7","format":"\n \n<table style=\"width:100%\">\n <tr>\n <th>Index</th> \n <th>Time</th>\n <th>Room</th> \n <th>ID</th>\n </tr>\n <tr ng-repeat=\"x in msg.payload | limitTo:10\">\n <td><center>{{$index}}</center></td>\n <td><center>{{msg.payload[$index].date}}</center></td>\n <td><center>{{msg.payload[$index].room}}</center></td> \n <td><center>{{msg.payload[$index].id}}</center></td>\n </tr>\n</table>\n","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":false,"templateScope":"local","x":520,"y":560,"wires":[[]]},{"id":"284382e1.7b6bde","type":"comment","z":"effec76.43dd238","name":"MariaDB","info":"https://mariadb.org/\n\n//SELECT COUNT(*) FROM RANDOMNUM\n//SELECT COUNT(*) FROM `test`\n// UPDATE RANDOMNUM SET BOOL = 1 WHERE VALUE > 20 AND BOOL = 0\n\n//UPDATE `test`.`access` SET `room`='602' LIMIT 1;\n\n//DELETE FROM RANDOMNUM WHERE TIMESTAMP <= strftime('%s','now', '-30 seconds')*1000\n\n//DELETE FROM `test`.`access` WHERE `no`=3 AND `time`='2021-06-07 17:37:03' AND `room`=503 AND `id`=1893 LIMIT 1;\n","x":140,"y":80,"wires":[]},{"id":"16d49f4f.2f72e1","type":"function","z":"effec76.43dd238","name":"TABLE","func":"topic = \"CREATE TABLE `access` ( \";\ntopic = topic + \"`no` INT NULL AUTO_INCREMENT,\";\ntopic = topic + \"`date` TIMESTAMP NOT NULL,\";\ntopic = topic + \"`room` INT NULL,\";\ntopic = topic + \"`id` INT NULL,\";\ntopic = topic + \"INDEX `no` (`no`)) COLLATE='latin1_swedish_ci';\";\nmsg.topic = topic;\n\nreturn msg;","outputs":1,"noerr":0,"x":330,"y":200,"wires":[["392b8ab7.e19ac6"]]},{"id":"982a5d4d.e294f","type":"inject","z":"effec76.43dd238","name":"CREATE","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":160,"y":140,"wires":[["3648a443.b264bc"]]},{"id":"8f16a404.412c08","type":"debug","z":"effec76.43dd238","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":690,"y":140,"wires":[]},{"id":"3648a443.b264bc","type":"function","z":"effec76.43dd238","name":"DATABASE","func":"var newMsg = {\n\"topic\" : \"CREATE DATABASE `test`;\"\n}\nreturn newMsg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":350,"y":140,"wires":[["1c79da55.f69436"]]},{"id":"8094763.a62db88","type":"function","z":"effec76.43dd238","name":"DELETE ","func":"var newMsg = {\n\"topic\" : \"DELETE FROM `test`.`access` ORDER BY no DESC LIMIT 1\"\n}\nreturn newMsg;\n","outputs":1,"noerr":0,"x":340,"y":320,"wires":[["30524e2a.cfc672"]]},{"id":"86051971.03c5c8","type":"function","z":"effec76.43dd238","name":"UPDATE","func":"var newMsg = {\n\"topic\" : \"UPDATE `test`.`access` SET `room`='602' ORDER BY date DESC LIMIT 1;\"\n}\nreturn newMsg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":340,"y":380,"wires":[["9112997a.e12398"]]},{"id":"4f194982.db8818","type":"function","z":"effec76.43dd238","name":"COUNT","func":"var newMsg = {\n\"topic\" : \"SELECT COUNT(*) FROM `test`.`access`;\"\n}\nreturn newMsg;\n","outputs":1,"noerr":0,"x":340,"y":440,"wires":[["ef30769c.f2b218"]]},{"id":"6bb93345.de551c","type":"debug","z":"effec76.43dd238","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload[0]","targetType":"msg","x":700,"y":440,"wires":[]},{"id":"2fa7fa16.df7d36","type":"function","z":"effec76.43dd238","name":"SELECT","func":"var newMsg = {\n\"topic\" : \"SELECT * FROM `test`.`access` ORDER BY date DESC LIMIT 20;\"\n}\nreturn newMsg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":340,"y":500,"wires":[["dd12c746.831c48"]]},{"id":"6d7d1453.5a80ec","type":"function","z":"effec76.43dd238","name":"Date to TS","func":"\nfor(var i = 0; i < msg.payload.length; i++){\n var dd = new Date(parseInt((new Date(msg.payload[i].date).getTime()).toFixed(0)));\n msg.payload[i].date = dd.toLocaleTimeString('it-IT');\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":350,"y":560,"wires":[["99b466a0.219ac8"]]},{"id":"fdbcc9a.f22b838","type":"mysql","z":"effec76.43dd238","mydb":"2236dfd1.c909e","name":"","x":510,"y":260,"wires":[["7286764d.703128"]]},{"id":"392b8ab7.e19ac6","type":"mysql","z":"effec76.43dd238","mydb":"2236dfd1.c909e","name":"","x":510,"y":200,"wires":[["d8886e88.2e352"]]},{"id":"1c79da55.f69436","type":"mysql","z":"effec76.43dd238","mydb":"2236dfd1.c909e","name":"","x":510,"y":140,"wires":[["8f16a404.412c08"]]},{"id":"30524e2a.cfc672","type":"mysql","z":"effec76.43dd238","mydb":"2236dfd1.c909e","name":"","x":510,"y":320,"wires":[["ee3ecafb.5dddf8"]]},{"id":"9112997a.e12398","type":"mysql","z":"effec76.43dd238","mydb":"2236dfd1.c909e","name":"","x":510,"y":380,"wires":[["26081a12.74a426"]]},{"id":"ef30769c.f2b218","type":"mysql","z":"effec76.43dd238","mydb":"2236dfd1.c909e","name":"","x":510,"y":440,"wires":[["6bb93345.de551c"]]},{"id":"dd12c746.831c48","type":"mysql","z":"effec76.43dd238","mydb":"2236dfd1.c909e","name":"","x":510,"y":500,"wires":[["cb4de9f3.133428"]]},{"id":"cb4de9f3.133428","type":"link out","z":"effec76.43dd238","name":"","links":["d5f68b78.692828","2061246d.5ba25c","33c14cb5.0c0b14","8b2213ea.cbdaa"],"x":635,"y":500,"wires":[]},{"id":"2061246d.5ba25c","type":"link in","z":"effec76.43dd238","name":"","links":["cb4de9f3.133428"],"x":195,"y":560,"wires":[["6d7d1453.5a80ec"]]},{"id":"eed4bf37.31aee","type":"ui_group","name":"[ Access Data of Class Room ]","tab":"6d23db44.1697d4","order":1,"disp":true,"width":"6","collapse":false},{"id":"2236dfd1.c909e","type":"MySQLdatabase","z":"","name":"","host":"127.0.0.1","port":"3306","db":"test","tz":"","charset":""},{"id":"6d23db44.1697d4","type":"ui_tab","name":"Main Tab","icon":"dashboard","order":1}]