There are instructions on the readme of the node-red-node-sqlite that shows you how to do prepared statements
As was stated earlier you need quotes round strings. I suggest you use the template literal syntax, it is much easier to get embedded quotes right. So something like
sql = `INSERT INTO gpstrack (Time) VALUES ( '${msg.payload.Time}' )`
Those are backticks around the whole string.
Alternatively it may well be easier to use a Template node to build to the sql query in msg.topic.
Many thanks.....i am starting to get data in the db
In the function you posted, what is all that stuff with the outputs array about? As far as I can see all you should need is
msg.topic = `INSERT INTO gpstrack (Time) VALUES ( '${msg.payload.Time}' ... )`
return msg
Excellent. Now you can convert to using Prepared queries so that your db cannot be trashed by faulty data in the csv file.
Can you give me an examples of a "prepared query". i have no idea how to use it
As has been pointed out at least twice, this is described in the help text for the node, which can be seen in the right hand pane in the editor. Also at node-red-node-sqlite (node) - Node-RED
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.