The following tutorial will teach us how to resolve the error
database is locked in SQLite. Often, this issue is faced when the system has intentionally or unintentionally locked a database.
Unlock the SQLite Database in Windows
In Windows, the simplest thing is finding the process that is handling the database file. We can use this program to determine the process.
After closing the process, the database would be unlocked.
Unlock the SQLite Database in macOS and Ubuntu
We will do a similar thing mentioned above in these systems as well. Just the procedure of finding the process handling the database might be different.
To find it out, we must perform the following operations:
Suppose our DB file is
$ fuser demo.db
The below command will show the process that is causing the file to get locked:
> demo.db: 5430
The final step lies in killing the process is:
kill -9 5430
Doing the above steps will unlock the DB file for us. Hence, we can counter the error
database is locked in SQLite on various operating systems, including macOS, Windows, and Ubuntu.