Skip to content

SQLite 'database is locked' when two scripts write at the same time

tom_hartley0 views

I have a script that loads data every few minutes and a second one that updates a status table. When they overlap, one of them fails with sqlite3.OperationalError: database is locked.

They both open the same file. Do I have to switch to PostgreSQL, or is there a setting that helps?

Loading the replies

Your reply

Be kind and specific. Read the community guidelines.

Choose what we may use. You can change this at any time with “Privacy choices” at the foot of every page. Details are in the Cookie policy and the Privacy policy.

Strictly necessary

Remembers your theme, the lessons you marked as done and this choice. It stays on your device, tracks nothing and cannot be switched off.

Always on
What exactly is collected, and why

Grokem’s own counts

Collects
The pages you open and how long you stay, how far you scroll, where you came from, your device type, browser, screen size, language and time zone. Your IP address is turned into a code that changes every day; it is never stored as it is.
Why
To see how long lessons are read and where readers leave. Not shared with anyone.
Stored
A random visitor ID, a visit ID and the time of your last page view in your browser’s storage (gr_vid, gr_sid, gr_last). No name or email is attached.
SQLite 'database is locked' when two scripts write at the same time | Grokem