How to insert data with this string value and how to split it, i new for using node-red

help me for this problem

Welcome to the forum.

Doesn't the payload need to be an array not a string? Check the help pane for the node.

Thanks for answer mr.collin, i try like this


but i still get error

It is very difficult for me to read that screenshot but it looks as if you have some quotes in the wrong place. When posting code in the future please paste it in using the method described in How to share code or flow json

var str = msg.payload;
var parts = str.split(" ");
x = parts[0];
y = parts[1];
percobaan_id = parts[2];
var hari = msg.myymd;
var jam = msg.mytimes;
var waktu = hari+" "+jam;
//var waktu = date.getTime();
msg.topic = "INSERT INTO eye_fixation(x,y,time,percobaan_id) VALUES("+x+", "+y+","+waktu+", "+ percobaan_id +")";
return msg;

and this my error :
image

Your SQL syntax is wrong, as the error says. You probably need quotes round the values or something. Check the mariadb docs as the error suggests.

image

ok thanks, it solved just missing ' '

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