I have this set up in Node Red:
Using this SQL (Function) code:
msg.topic = "INSERT INTO temperature(temp, date) VALUES('" +
msg.payload + "', 'NOW()')";
return msg.topic;
And getting this error:
function : (error)
"TypeError: Cannot create property '_msgid' on string 'INSERT INTO
temperature(temp, date) VALUES('1.23', 'NOW()')'"
What am I doing wrong?
Your function is just returning a string (msg.topic), it needs to return a whole object.
msg.topic = "INSERT INTO temperature(temp, date) VALUES('" + msg.payload + "', 'NOW()')";
return msg;