POSIX advisory locking is known to be buggy or even unimplemented on many NFS implementations
(including recent versions of Mac OS X)
and that there are reports of locking problems for network filesystems under Windows.
So, the **rule of thumb** is to avoid using SQLite3 on network filesystems (Samba, NFS, etc).
You are guaranteed to encounter issues in the long run
(even though there lots articles talking about ways to alleviate the problem).
Use JSON (on NFS) if you don't really need database
or use MySQL, etc. if a database is needed.Use the
autocommitmode by using the optionisolation_level=Nonewhen you use thesqlite3module in Python. Notice that even if SQLite3 usesautocommitby default, the Python modulesqlite3does not haveautocommitturned on by default.
Ways to Fix The Error “OperationError: Database is locked”¶
The best practice is to create a backup of the datase which has no locks on it. After that, replace the database with its backup copy.
Sqlite> .backup main backup.Sqlite
Sqlite> .exit
$mv .x.Sqlite old.Sqlite
$mv backup.Sqlite .x.SqliteYou can also directly make a copy of the original SQLite3 file to backup it.
References¶
https://
https://
Can SQLite and TDB databases be used with NFS?
How do I unlock a SQLite database?
“The database file is locked” error even when the file is newly created
https://
OperationalError: database is locked
How to know which process is responsible for a “OperationalError: database is locked”?