Sorry, here is the full flow
[{"id":"94608d98.67353","type":"mqtt in","z":"8e0d9d8d.74dab","name":"mq135","topic":"gas","qos":"2","datatype":"auto","broker":"5aea07cc.587608","x":93.62965774536133,"y":145.74074840545654,"wires":[["6b26dad.2402924","434c09c4.654a08"]]},{"id":"6b26dad.2402924","type":"debug","z":"8e0d9d8d.74dab","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":533.8518142700195,"y":109.85188007354736,"wires":[]},{"id":"b4c2604c.6ccfd","type":"sqlite","z":"8e0d9d8d.74dab","mydb":"8e6657de.de04b8","sqlquery":"msg.topic","sql":"","name":"db","x":539.7777633666992,"y":298.7407474517822,"wires":[["6b26dad.2402924"]]},{"id":"209c7162.3a851e","type":"inject","z":"8e0d9d8d.74dab","name":"","topic":"","payload":"fxsdfsdfxd","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":123.01953125,"y":288.00390815734863,"wires":[["434c09c4.654a08"]]},{"id":"434c09c4.654a08","type":"function","z":"8e0d9d8d.74dab","name":"INSERT","func":"var newMsg = {\n \"topic\": \"INSERT INTO mq(valor) VALUES (\"+msg.payload+\")\"\n}\nreturn newMsg;\n","outputs":1,"noerr":0,"x":312.5234375,"y":210.88284873962402,"wires":[["b4c2604c.6ccfd","6b26dad.2402924"]]},{"id":"5aea07cc.587608","type":"mqtt-broker","z":"","name":"Core","broker":"172.20.10.2","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"8e6657de.de04b8","type":"sqlitedb","z":"","db":"/home/pi/test.db","mode":"RWC"}]
-
I created the table on the Raspbian terminal with SQLite. CREATE table mq(valor varchar(20))
-
I used a function node to create the insert query
var newMsg = {
"topic": "INSERT INTO mq(valor) VALUES ("+msg.payload+")"
}
return newMsg;
- Yes, there is a debug node. I used a inject node to test inserting letter or words and this is the error I get.