4 ms·
Not 100% certain about this, but I can give my understanding and some links. Have a look at https://www.sqlite.org/faq.html#q5 https://www.sqlite.org/faq.html#
by onli 5y ago
Not 100% certain about this, but I can give my understanding and some links.
Have a look at https://www.sqlite.org/faq.html#q5 https://www.sqlite.org/faq.html#q5. Multiple process can have the database open. Multiple processes can read the database simultaneously. Only one process can write to the database at each moment.
For the above to be true WAL has to be enabled. Otherwise writes in the one process will block reads from other processes. You can test this with two simple scripts that write and read with an uneven interval from the database (I have an example for that under [0], german, but with code).
I think the idea is that you can also have multiple process that write, they just have to set a timeout and retry. That's not the default configuration, not with the sqlite libs I know at least. But if write processes just retry then that should also work. PRAGMA busy_timeout should be the keyword here, or handling it manually by catching the timeout exception and retrying.
I usually try to avoid that scenario regardless, one process that writes and many that read worked for me for everything so far.
[0]: https://www.onli-blogging.de/1886/Eine-SQLite-Datenbank-mit-mehreren-Prozessen-teilen.html https://www.onli-blogging.de/1886/Eine-SQLite-Datenbank-mit-...