How to refresh my sqlite 3 database through node red

Yes sir , i want to export my sqlite into csv file how can i do that

@shipra as I've suggested in other threads... break it down into steps.

You have data in a an sqlite database, you want it in a file. What are the steps your flow needs to take to do that? Write down that list of steps, then think about how you can complete each step.

I thought you wanted to update the view in the database browser.

i have tried this please check and suggest

I am getting this error

9/21/2020, 6:18:45 PMnode: Writing into .csv filefunction : (error)
"Function tried to send a message of type string"

My csv function looks like this

if (msg.payload=="Refresh_DataBase")
   var data= "SrNo"+ "," + "Date_and_Time_India"+ ","+"Date_and_Time_UK"+ ","+"Event_Type"+ "," +"Event_Description"+ ","+"Person_ID"+ ","+"Person_Name_Description"+ ","+"Fob_Tag_ID"+ ","+"Trade_ID "+ ","+"Door_ID"+ ","+"Door_Description"+ ","+"Status"

return msg.payload1;

please suggest where i am doing wrong

ye sir i want how can i expost my sqlite into csv file

Where is the list of steps you think the code should be taking? It is impossible to look at a flow and know what you are thinking.

The error is exactly what it says - your Function code is returning msg.payload1 which is a String. It should be returning msg.

Sir my steps are like this
User enter Fob id->if valid then insert a row in my DB(image attached)->store into a csv file
user enter tag id->////////same as above///////////
user enter tag+fob id ->///////same as above///////////

So every time you update a row in the sqlite database, you also want to write the whole database out as an CSV file?

So lets focus on the steps to get the data out of the database and into the file. What steps does your flow need to take to do that? And which part of those steps do you need help on?

Sir i tried this and getting some output like this

I want to upload my whole DB into csv which is not coming why?

yes please tell how can i do that?

I am very patiently trying to get you to figure it out.

Yet again you have posted a screenshot and asked me what it isn't working. You have not provided any information about what that screenshot shows or what is not working about it.

You have also not answered the questions I asked. So let me try to spell it out. You need a flow that can:

  1. get all the data from the database
  2. format that data appropriately
  3. write it to a file.

Let us focus on these steps. Here are some questions for you to answer.

  1. what node do you use to query the database?
  2. what SQL query do you need to use to get the data from the database?
  3. how do you pass that query to the database node?
  4. What node can you use to look at the result of the database query in order to understand the structure of the data you are getting back?
  5. What node in the palette can you use to generate CSV (hint: not the Function node...)

yes sir i want this.


I replaced my older query and wrote this
let newMsg1={};

return newMsg1;

but not getting the output in csv file

ok then how can i do this?

I give up. Use the CSV node. If you had spent 30 seconds looking you would have found it.

Sir i get my DB into csv but one issue is coming new SrNo is not coming in a new line why?

You haven't shared any information about your flow. I can no longer help you. Good luck.

I have asked you repeatedly to provide enough information to for us to help you. Given you seem unwilling to learn or to listen to the advice you are given, I cannot spend more of my free time on this.

Sir, sorry but duw to my english maybe you feel like i am not listening or not obeying you but that not the case i am properly following you .
my flow
Database i want in csv file.
the things i tried
I have taken one refresh pub node whenever i publish on this node by older stored value whatever will be in DB previously it should get stored in csv file format
For this i have taken

  1. REFRESH PUB node so that it should trigger my csv file generation
  2. func node where i have written SELECT * FROM NCS_DATABASE2;
    3)csv file node where i have given my csv file directory.

I am getting like this

It is not looking good i mean headers and data all are getting in one row ,So kindly tell how can i do it in proper manner

So you are selecting all the data from the database. Good.

I am guessing (because you have not shown us), that you think you can just write the result of the database query straight to a file and expect it to be in the right format.

That is not how it works.

Look again at the list of 3 steps I described you having to do:

  1. get all the data from the database
  2. format that data appropriately
  3. write it to a file.

At the moment it sounds like you are doing 1 and 3 - but you are not doing 2.

I have suggested you look at the CSV node in the palette. This can be used to take the result of the database query and generate valid CSV for you. You say you are listening to me, but I see no evidence that you have looked at the CSV node yet.

1 Like

Sir ,you are genius .thank you so much and sorry for the I am getting the output in correct format