How to Unlock the SQLite Database

Preet Sanghavi Feb 02, 2024
  1. Unlock the SQLite Database in Windows
  2. Unlock the SQLite Database in macOS and Ubuntu
How to Unlock the SQLite Database

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 demo.db:
    $ 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.

Preet Sanghavi avatar Preet Sanghavi avatar

Preet writes his thoughts about programming in a simplified manner to help others learn better. With thorough research, his articles offer descriptive and easy to understand solutions.

LinkedIn GitHub

Related Article - Python SQLite