Hi, I not understand what the six "+ " are for in => "topic": "INSERT INTO RANDOMNUM VALUES ( " + msg.payload + ", " + randomNum + ", " + largeBool + ")" , can you explain that please?
==Node-REd Sample== [{"id":"d7d8970e.1187f8","type":"inject","z":"dcadcc70.cbb14","name":"CREATE DB","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"CREATE TABLE REALTEST( TIMESTAMP INT PRIMARY KEY NOT NULL, VALUE REAL NOT NULL, BOOL INT NOT NULL)","payload":"","payloadType":"date","x":170,"y":160,"wires":[["7492730b.ba965c"]]},{"id":"e4811fc4.817d2","type":"inject","z":"dcadcc70.cbb14","name":"INSERT","props":[{"p":"payload","v":"","vt":"date"},{"p":"topic","v":"","vt":"string"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":160,"y":220,"wires":[["645016a4.107e38"]]},{"id":"645016a4.107e38","type":"function","z":"dcadcc70.cbb14","name":"INSERT","func":"// var randomNum = Math.round(Math.random()*100); var randomNum = 11.1; var largeBool = (randomNum > 50)?1:0; var newMsg = { \"topic\": \"INSERT INTO REALTEST VALUES ( \" + msg.payload + \", \" + randomNum + \", \" + largeBool + \")\" } return newMsg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":320,"y":220,"wires":[["7492730b.ba965c"]]},{"id":"7bf8c1d6.e001c","type":"inject","z":"dcadcc70.cbb14","name":"SELECT","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"SELECT * FROM REALTEST ORDER BY TIMESTAMP DESC LIMIT 100;","payload":"","payloadType":"date","x":160,"y":280,"wires":[["6997e246.5f048c"]]},{"id":"6997e246.5f048c","type":"sqlite","z":"dcadcc70.cbb14","mydb":"885285ef.597a18","sqlquery":"msg.topic","sql":"","name":"db_002","x":480,"y":280,"wires":[["1b33ca13.9e8d86","6f25463b.938928"]]},{"id":"1b33ca13.9e8d86","type":"ui_template","z":"dcadcc70.cbb14","group":"a58c558e.b6c788","name":"","order":0,"width":"6","height":"7","format":"
Thank you for teaching you how to add, delete and display information in Node-Red.
thank you very much for your help.
A very nice tutorial. Thanks alot!
Hi, I not understand what the six "+ " are for in => "topic": "INSERT INTO RANDOMNUM VALUES ( " + msg.payload + ", " + randomNum + ", " + largeBool + ")" , can you explain that please?
Hi there, How can you display decimals (like 10.20 for example) ? I am looking forward to display a REAL filed type from the database.
Create a DB as shown below.
CREATE TABLE REALTEST( TIMESTAMP INT PRIMARY KEY NOT NULL, VALUE REAL NOT NULL, BOOL INT NOT NULL)
==Node-REd Sample==
[{"id":"d7d8970e.1187f8","type":"inject","z":"dcadcc70.cbb14","name":"CREATE DB","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"CREATE TABLE REALTEST( TIMESTAMP INT PRIMARY KEY NOT NULL, VALUE REAL NOT NULL, BOOL INT NOT NULL)","payload":"","payloadType":"date","x":170,"y":160,"wires":[["7492730b.ba965c"]]},{"id":"e4811fc4.817d2","type":"inject","z":"dcadcc70.cbb14","name":"INSERT","props":[{"p":"payload","v":"","vt":"date"},{"p":"topic","v":"","vt":"string"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":160,"y":220,"wires":[["645016a4.107e38"]]},{"id":"645016a4.107e38","type":"function","z":"dcadcc70.cbb14","name":"INSERT","func":"// var randomNum = Math.round(Math.random()*100);
var randomNum = 11.1;
var largeBool = (randomNum > 50)?1:0;
var newMsg = {
\"topic\": \"INSERT INTO REALTEST VALUES ( \" + msg.payload + \", \" + randomNum + \", \" + largeBool + \")\"
}
return newMsg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":320,"y":220,"wires":[["7492730b.ba965c"]]},{"id":"7bf8c1d6.e001c","type":"inject","z":"dcadcc70.cbb14","name":"SELECT","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"SELECT * FROM REALTEST ORDER BY TIMESTAMP DESC LIMIT 100;","payload":"","payloadType":"date","x":160,"y":280,"wires":[["6997e246.5f048c"]]},{"id":"6997e246.5f048c","type":"sqlite","z":"dcadcc70.cbb14","mydb":"885285ef.597a18","sqlquery":"msg.topic","sql":"","name":"db_002","x":480,"y":280,"wires":[["1b33ca13.9e8d86","6f25463b.938928"]]},{"id":"1b33ca13.9e8d86","type":"ui_template","z":"dcadcc70.cbb14","group":"a58c558e.b6c788","name":"","order":0,"width":"6","height":"7","format":"
Index
Timestamp
Value
Bool
{{$index}}
{{msg.payload[$index].TIMESTAMP}}
{{msg.payload[$index].VALUE}}
{{msg.payload[$index].BOOL}}
","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":false,"templateScope":"local","x":660,"y":280,"wires":[[]]},{"id":"6f25463b.938928","type":"debug","z":"dcadcc70.cbb14","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":670,"y":320,"wires":[]},{"id":"7492730b.ba965c","type":"sqlite","z":"dcadcc70.cbb14","mydb":"885285ef.597a18","sqlquery":"msg.topic","sql":"","name":"db_002","x":480,"y":220,"wires":[[]]},{"id":"885285ef.597a18","type":"sqlitedb","z":"","db":"db_002","mode":"RWC"},{"id":"a58c558e.b6c788","type":"ui_group","name":"Group 1","tab":"2375ea1e.32e386","order":1,"disp":true,"width":6},{"id":"2375ea1e.32e386","type":"ui_tab","z":"","name":"Main Tab","icon":"dashboard","order":1}]
감사합니다
Where is the commentary?? I'm here to learn not be entertained....
THX