Can I read and write to a SQLite database concurrently from multiple connections?

后端 未结 2 389
鱼传尺愫
鱼传尺愫 2020-11-28 04:25

I have a SQLite database that is used by two processes. I am wondering, with the most recent version of SQLite, while one process (connection) starts a transaction to write

2条回答
  •  佛祖请我去吃肉
    2020-11-28 05:24

    I collected information from various sources, mostly from sqlite.org, and put them together:

    First, by default, multiple processes can have the same SQLite database open at the same time, and several read accesses can be satisfied in parallel.

    In case of writing, a single write to the database locks the database for a short time, nothing, even reading, can access the database file at all.

    Beginning with version 3.7.0, a new “Write Ahead Logging” (WAL) option is available, in which reading and writing can proceed concurrently.

    By default, WAL is not enabled. To turn WAL on, refer to the SQLite documentation.

提交回复
热议问题