Getting Null instead of data in sqlight database

Hi, hope this is an easy question, I am trying to add data to a spreadsheet and I get null in the spreadsheet if I try and use my variable but if I input a number it works correctly.

If I do the function like this it inserts 55 in the spreadsheet in the correct column

But when doing it this way, I thought it would put the 2282 in the spreadsheet but it just puts null. I am sure you can tell I know nothing about programing in this language so not sure if the syntax is correct for what I want to do.

The variable is coming from reading a number from a PLC using modbus. This is how I am reading and making in variable PV. Getting the data from modbus seems to be working correctly but I am not sure if I the function to make the variable is correct or not.

The debug is showing the number correctly my issue seems to be when writing to the database.I have the data type set to integer but have tried others with no luck.

Thank you for any help and hope I gave the information needed .

It only let me add 2 pictures.

Eric

Here is the other picture I wanted to post.

Hi Eric, welcome to the forum

Firstly, it is preferable to share text not pictures (since text can be copied and pasted back, can be searched, and is easier to read). For debug messages, you can use the copy value button

So, what is important to know is the actual node you are using. Your title says "sqllight" and your content says "spreadsheet"

At a guess you are using node-red-node-sqlite (node) - Node-RED

If you read that OR the built in help (which you can find on the right hand Sidebar inside of the node-red editor) it says to use named parameters and msg.payload should be an array

When using Via msg.topic, parameters can be passed in the query using a msg.payload array. Ex:

msg.topic = `INSERT INTO user_table (name, surname) VALUES ($name, $surname)`
msg.payload = ["John", "Smith"]
return msg;

Hi Steve,

Thanks for the welcome and advice for further post of questions.

Yes, your guess is correct I am using node-red-node-sqlite sorry for the confusion from my end.

Thank you for the link to get the correct information, the tutorial I was using was working well up to writing to the DB. After using the information you supplied it is working correctly now.

Thanks again,

Eric

1 Like

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