I'm using sqlite to write to a db on local storage. In trying to make the entire system as automated as possible so I have earlier nodes that check to make sure the destination directory exists and if not creates it.
Problem is that when the entire flow is initialized if the directory does not exist the sqlite node errors out. Later, when the directory has been created and I trigger the sqlite node, it does not attempt to find the directory and stays in an error state.
Is there any way to fix this?
Welcome to the forums @OkimSelim.
Config Nodes are started before any Nodes in your flow (so your attempt wont work)
so sadly - there isn't any immediate fix.
How are you starting Node RED?
You could mkdir
before starting Node RED perhaps, so the directory is there before the DB file is created at that location (and importantly before Node RED starts)?
I don't do much SQLite - so there maybe other options @dceejay?
I agree with Marcus, either use your startup script or even settings.js to ensure that the folder is present. Your settings.js file may be easiest. It is automatically run by Node-RED early in the startup process. Just remember not to blindly overwrite it if a new version of node-red comes along with changes to that file.
1 Like
I like the settings file approach.
using the built in fs module can create the directory - Noice!
1 Like