Correct syntax for SQL select query in template node


I wan't to query my postgres database (just a simple select query), but I can't figure out the syntax in my template node. The debug windows shows: "Error: msg.payload must be an array of queries"

Any idea how to write a correct sql select query?

Thanks in advance :pray:

Regards Morten

msg.topic = `here SQL or ${variable} string;`
return msg;

Before connecting to the sql node, feed the template into a debug node and check it is showing the query correctly.
What payload is going into the template and what query do you want out?

What have you tried in the template node and what did it give out?
Make sure you have read the help text for the template node carefully.

[Edit] Also which postgress node have you installed? Probably node-red-contrib-something.

What is the property of template node set to? is it msg.payload or msg.topic ? for sql query it is required to be a msg.topic. you may also use a change node to convert msg.payload to msg.topic


Thank you for your reply :+1: I finally solved it by my self. I found another postgres node, where I could put in my SQL query and i works perfect. Thanks for your quick reply and input anyway.

Regards Morten

For others that find this please share which node you used that worked for you.

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