Function node, edit message is not working in database

I am using the nodes in the picture below to write an integer in a label(dashboard) and write it in a database.

You can see the code of the function node in the picture to Update the database with the variable.

However, in debug appears "Error: Unknown column 'power' in 'field list'
Can someone help me??

The way you pass your parameter isn't correct. Basically you're telling MySQL to set the value of potencia to the value of another column named power, which doesn't exist.

Try using a placeholder ? in your query and pass the parameter as payload in an array.
That also has the benefit of preventing SQL injections, since the mysql lib will take care of any escaping.

msg.topic = "... set potencia=? where ..." // omitted the rest
msg.payload = [power];

Yeah. It works. Thank you....

1 Like

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