N
N
Nauryzbek Aitbaev2019-01-21 08:50:34
Django
Nauryzbek Aitbaev, 2019-01-21 08:50:34

Django. Why does database locked appear when the database is updated every 20 seconds?

There is a model in Django which has online_user and online_date properties. When one user visits the page, they get edit access: online_user is set to that user, and online_date is set to the current date. And this page sends an ajax request every 20 seconds which updates this online_date. So, sometimes another user gets a Django server error, which says that the database is locked. How to solve this problem? The database costs SQLite.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
smsi, 2019-01-21
@NaurizAitbai

By default, multiple processes can open the same SQLite database at the same time, and multiple read requests can run in parallel.
In the write case, a single write to the database locks the database for a short time, nothing, not even a read, can access the database file at all.
https://stackoverflow.com/questions/10325683/can-i...
Change database to MySQL or PostgreSQL - these locks are not there

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question