I currently have two different processes, one process writes into a database and the other one reads and updates the records in the database that were inserted by the first process. Every time I try to start both processes concurrently the database gets locked, makes sense. Due to simultaneous read and write. I came across WAL, but haven't been able to come across any example as to how to enable WAL in a c++ code. Any help would be appreciated. Thanks.
Asked
Active
Viewed 507 times
-1
-
Does SQLite allow concurrent access from *different* processes? I thought it was locked to do that within one process only. If you need a more robust database, consider Postgres or something explicitly designed for concurrent, multi-process access. – tadman Nov 26 '20 at 10:23
-
@tadman: Looks like SQLite can use shared memory. Postgres can work across different _computers_. That's still an issue with SQLite. – MSalters Nov 26 '20 at 12:35
-
@MSalters I believe concurrency was something achievable using write ahead logging. Or am I mistaken? – atomic_barf Nov 26 '20 at 13:35
-
I'm not sure about the concurrency facilities available between processes both accessing the same database. In my experience SQLite performs very well with one process, but tends to under-perform when there's contention for the same resource. – tadman Nov 26 '20 at 19:34
1 Answers
0
To activate it, as per the documentation you just need to run the following statement:
PRAGMA journal_mode=WAL
This is persistent and only needs to be applied once.

tadman
- 208,517
- 23
- 234
- 262