SQLite insert problem

Hello 'Im having a problem when I want to insert a variable in my data base, the variable is an flow variable that I took from a drop down list.
when call it it says that is a char type variable but at the moment of inserting it say that there is not a column object, Object

I dont know if there is any other syntax to insert a variable.
here is my flow
[{"id":"6a83cdb5.ea90e4","type":"function","z":"a44c1a9a.8dd15","name":"","func":"\n//var dia = new Date().toLocaleString("es-MX").slice(0,15);\n//var hora = new Date().toLocaleString("es-MX").slice(11,15).replace(/:/,"-");\n\nvar area=flow.get('garea');\nvar newMsg = {\n "topic": "INSERT INTO DATA (area,supervisor,operador,material,cantidad,fecha)"+ "VALUES("+area+",'CARLOS','ANDRES','TALADRO',5,"+msg.payload+");"\n}\n\nreturn newMsg;","outputs":1,"noerr":0,"x":860.5,"y":90,"wires":[["1fd7cd42.7c509b"]]}]

I created the Table from outside and checked that the index is a "text" type

Looks like one of the variables you're using is an object, what are the data types of area and msg.payload?

Area is a char type
and msg payload is a timestamp from the injection node

Unfortunately your flow isn't importable.

Add a debug to the output from your function and change the debug settings to
Output complete message object

Then you will see the msg.topic you are sending and hopefully where the error is

I'm using an Sqlite insert always like this, works fine for me.
On the payload line you can place all your variable, it's easier then putting them inside the "insert into" string.

var version="1.01";
var temp = 23.5

 msg2.topic = "INSERT INTO TempSensor (timestamp,nodeid,versie, temperatuur, luchtvochtigheid,status) VALUES (?,?,?,?,?,?)";
 msg2.payload = [new Date(), 101, version,temp, luchtv, status]; 

return msg2;

1 Like

That works?

The ) at the end should be a ] , typo :wink:
Changed in my first reply.

+1, also safer to do it this way with the ?'s, as the inputs are sanitized.

I tried ir but I still have the error , but I checked and realize that the problem was that i was calling the variable as an object and not his payload.

the solution was to call it like this

thank you for the help :slight_smile: