You will find the node settings I used in the code export in my earlier post. From memory, the node is very particular, and I think read only requires prepared statements, and even if you don’t use parameters in the statement, msg.payload input needs to be an empty object {}.
I have tried again with the docker mounting the home-assistant_v2.db file as rw and changed the sqlite node to RWC mode. It still generated the same error.
It seems to be something else with my configurations. Let me dig deeper.
I have tested with a sqlite database file created by node-red-node-sqlite. It was fine.
However, for the sqlite file home-assistant_v2.db mounted from HA. It always throws the error Error: SQLITE_READONLY: attempt to write a readonly database even when I have chown’ed the file to 1000, the default user id of node-red container.
Home Assistant and Node-RED are run in their separated docker containers.
The SQLite DB is file based, not server, so any connection has to be on the same physical machine. I use an HA Blue, fully supervised, and HA takes care of the docker containers and the required interconnections.
There is an SQLite Web interface add-on which adds easy access to the DB, and in Node-RED (add-on) I can use the file path /homeassistant/home-assistant_v2.db and the supervisor takes care of how it works. Other than that I have no idea of either the issue or a solution.
As you have found, posting on the Node-RED forum will typically prompt a suggestion to ask here as this is an “HA thing”, and posting here you may have to post outside of NR specifically, framing your question in terms of SQLite and containers.
I am happy to report that I have found the culprit. There are two more files accompany the sqlite database file home-assistant_v2.db that I have mounted inside the node-red container. The error is gone once I have mounted the extra files, home-assistant_v2.db-wal and home-assistant_v2.db-wal inside the node-red container.
One more question. What kind of helper entities do you use for the node-red to import the data into?
Edit: I discovered that Node-RED companion create the entity in Home Assistant.