You will need to check access on the Node RED process user to that file path, even select statements, might do some background (non destructive) writes - like a temp table for instance (the mode you mentioned will stop altering data, not necessarily system based tables it might need to do stuff with) and file permissions will play a part here
Given this is HA - it might be beneficial to refer to the HA forums, as if using the Node RED plugin - they will have the answers, in how Access is granted to plugins at certain file paths
I could be wrong here of course, but it's my best guess.
Thanks for your help. I have installed Home Assistant and Node-RED as 2 separated docker containers sharing a single user. I have verified the read permission inside the Node-RED container with docker exec. Here are the 2 compose.yaml files.
The SQLite node is reporting it cannot write to the DB. This looks like permissions.
If you know how docker works (it is like a virtual machine running inside a host) - that is where HA runs Node-RED (and so that is where the SQLite node is running also). Therefore, the account that runs the Node-RED process is an account inside the VM (aka docker container) and so, by the looks of the DB file path (/mnt/xxx/yyy) the DB is NOT inside the container but actually inside the host (the computer running HA / Docker host). Thats why I said:
I think there is confusion about exactly what you are complaining of. Is it that, when accessing a read only database, it is not possible to read from the DB?
20 Jun 17:21:27 - [info] [sqlitedb:137383098fbd7a8e] opened /mnt/ha2/config/home-assistant_v2.db ok
20 Jun 17:21:29 - [error] [sqlite:HA2] Error: SQLITE_READONLY: attempt to write a readonly database
20 Jun 17:25:25 - [error] [sqlite:HA2] Error: SQLITE_READONLY: attempt to write a readonly database
20 Jun 17:25:27 - [error] [sqlite:HA2] Error: SQLITE_READONLY: attempt to write a readonly database
Sorry for the confusion. I am not complaining. I know it must be my configuration errors.
I have stated the situation again with more information above. This time with the database access set to RWC mode and the read-write permissions of the database file of the node-red user inside the container verified. It still gave me the same error.
My next step would likely be to mount ../homeassistant/config with rw and do some simple file read/write tests (using the file nodes in node-red) to see if the node-red process has necessary permissions to the mounted fs. Next I would closely inspect the permissions of the db (though what these all are/should be is not something I am familiar with - HA folk will likely know how this is supposed to work off the top of their heads)
I am happy to report that I have found the culprit. There are two more files accompany the sqlite database file. The error is gone once I have mounted the extra files inside the node-red container. In my case, they are home-assistant_v2.db-wal and home-assistant_v2.db-shm.