Answer the question
In order to leave comments, you need to log in
How to avoid blocking BD?
Hello, for a month now I have been encountering an error every day:
sqlite3.OperationalError: database is locked
The database goes into lockdown and the project no longer functions, I fix transactions immediately after data updates.
But the error still remains and pops up after a day of bot work spontaneously, the only solution so far is one
Restart the project.
I tried prints to look for an error, but transactions are fixed normally and I don’t leave the database open. As I understand it, the error is due to the large load on the database. Switching to other bases is not an option for me
Answer the question
In order to leave comments, you need to log in
As I understand it, the error is due to the large load on the database. Switching to other bases is not an option for me
sqlite3.OperationalError
with the appropriate treatment
For a bot, it’s better to use a full-fledged base, of course. But since sqlite is critical, then check out the nuances of locks in the official wiki
. As a temporary solution, you can play around with timeout:
conn = sqlite3.connect(database, timeout=7) # стандартный таймаут 5 сек
How is the database accessed? Are there streams? how they work with a DB?
SQLite is a single user database with a single access point. She does not have the concept of sessions and access to it from different threads, and even more so under different accounts. Consider that you are pouring thousands of liters of water into the pool through the eye of the coal, using a siphon (funnel).
and where is the whole stack? at least on the insides of the sqlite package to see what you are pulling and with what it falls.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question