Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does select in SQLite3 lock the database?

Tags:

sqlite

I have one process constantly insert into a sqlite3 database and another process select from the sqlite3 database(slow sql).

Does sqlite3 lock the database on reads?

I want make sure every write success. Read fail is acceptable.

like image 591
everbox Avatar asked Feb 21 '23 15:02

everbox


1 Answers

According to SQLite3 locking reference after start of transaction (BEGIN command), a SHARED lock will be acquired when the first SELECT statement is executed. Shared lock means that the database may be read but not written. A RESERVED lock will be acquired when the first INSERT, UPDATE, or DELETE statement is executed.

like image 160
Mariusz Jamro Avatar answered Mar 08 '23 09:03

Mariusz Jamro