How to send MQTT string value to a postgres table


I have an MQTT node called "description" this node comes in as ASCII code from a PLC. The string node converts the ASCII code into a string value. I inserted debugs node so you can see how the message is moving. My function node has:

var query1 = "INSERT INTO testing (tech_name) VALUES ('" + msg.payload + "')";
msg.topic = "sql";
msg.payload = query1;
return msg;

I inserted a picture of the table I have in postgres and the data type the columns use. "tech_name" uses data type 'text' which should accept string values. I keep getting the error "error: invalid message format" even though I am using a string value

flows (2).json (3.7 KB)

That is the flow I am using

error: invalid message format

This means that the msg being sent to that node is not right.
Take at look here and here to check the proper way to contruct the message to send to the postgres node.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.