Hi, I'm trying to learn node-red and taking things one step at a time. I'm currently trying to store multiple sensor data to a mysql db with no luck. So, i tried to break it down by using an inject node, mysql node and a debug node. The mysql node shows connected to my local mysql server but when i click on the inject node i keep getting this error:
"Error: ER_EMPTY_QUERY: Query was empty"
My inject payload is set to string with the value:
INSERT INTO results (ldr) VALUES (20);
I'm simply trying to prove that i can insert the data decimal '20' into table 'results', column 'ldr'. When i run this same INSERT command in PHP on the same machine to the same DB, it works fine. I've tried adding quotation marks, apostrophes and every other combination with no luck. There is not much info on the web that i can find to help me and its getting quite frustration.
Help would be most welcome...kind regards...
Take a look at the info panel of the SQL node you are using ( its always useful if you specify which node you are using)
Assuming you are using node-red-node-mysql, the query isn't in msg.payload...
Hi, Sorry yes, I'm using what you have suggested. Yes, its in msg.payload with string (az)
So if you read the info panel as I suggested you will see
msg.topic must hold the query for the database, and the result is returned in
Those info panels are useful...
Hi, thanks for your replies but im still unsure. I learn best from following examples and thats what i was working from for this db test, which was obviously wrong!. Do you know of any mysql inject examples that I can look at??. kind regards...
msg.topic "INSERT INTO results (ldr) VALUES (20);"
Bingo... got it working by following the example flow:
'Log MQTT to MySQL'
That's all I needed to get me going.
Your help was invaluable...many thanks. Don...
This may due to not providing query or some reference error.