Just wanted to thank you again for your original post.
Just recently I came into an application that needed to be made using MYSQL and your syntax works wonders. There isn’t a lot of documentation on Node-RED syntax, so that tends to be what I struggle with most.
When I put numbers in the table these values are coming from, I get an “undefined” error but it writes my table correctly. When I put text in the same table I get this error:
I figure I’m not declaring something right but after a couple of hours, I’ve given up and thrown myself on the mercy of the forum.
EDIT: So the problem seems to be the string data type between what I’m declaring in the flow and what’s in the SQL database. When I make them all integers it works fine. Don’t know if that helps.
I got it to work. Benson saved the day. The issue was the conversion from a UTC string to one for MS SQL. I used the node in his sample flow and all is good.
Hi Guys,
I cannot get mine to work! I am doing the same thing as above but I cannot getting anything to write to the database. I have tried everything! What am I doing wrong?
Here’s the function code:
Can you post the output of the msg.payload prior to the function node.
Also, I have since learned that mustache templates do support arrays (it just isn’t in the documentation). To access array elements you use a period and the index like: {{{payload.3}}}
So you could skip the function node if you like and use:
INSERT INTO db_owner.MachineDATA (tempc, tempf)
VALUES ({{{payload.0}}}, {{{payload.1}}});
This won’t fix your problem though - need to see what is in the payload.
No errors on output. Actually nothing even shows up in debug. When I run the query to select anything from my columns, nothing is there and message says "0 rows effected."
What else can I look for?
I changed to ‘complete message object’ and still completely blank in debug. I should see something there right?
Here’s my DB connection in the MSSQL node. My usr name and password are correct, the address is correct.
The Opto Video is what got me started on this. I’ve studied it several times. If I check the encryption box, I do get an error in debug: "ConnectionError: Windows logins are not supported in this version of SQL Server."
I think it is Azure, so why would this not work?