I am trying to create daily sqlite3 databases.
I have a flow that
copy the existing db file to another location and
deletes the copied file
creates a new sqlite3 db file.
Create tables
Step 1,2 and 3 no issues. but when trying to create tables, it say table already exists. But the db file is empty with no tables. Any suggestions help!
How do you copy the file? You can't simple copy a sqlite file, most of the time it becomes unusable after copying due the fact that is already opened by the NR sqlitenode and the file can't be opened multiply times.
You can make a backup of the sql file with the exec node and the .backup option, for example /home/nodered/dbs/yourdata.sqlite ".backup /home/nodered/dbs/yourdata.sqlite.backup"
For the same reason I think you can't delete the file because it's in use by the the node-red-node-sqlite node and those strange thinks happen.
Best is to choose for a db that can handle large data sets, sqlite is not suitable for that.
Have look at Influxdb or mysql.
If you want still want to use sqlite, I think this will work, not tested.
Make a backup of the database file.
Empty the existing dbase file. (with the DELETE query)