How do I unlock a SQLite database?

How do I unlock a SQLite database?

In windows you can try this program to find out the process is handling db file. Try closed that program for unlock database

In Linux and macOS you can do something similar, for example, if your locked file is development.db:

$ fuser development.db

This command will show what process is locking the file:

> development.db: 5430

Just kill the process…

kill -9 5430

…And your database will be unlocked.

I caused my sqlite db to become locked by crashing an app during a write. Here is how i fixed it:

echo .dump | sqlite old.db | sqlite new.db

Taken from:

How do I unlock a SQLite database?

The SQLite wiki DatabaseIsLocked page offers an explanation of this error message. It states, in part, that the source of contention is internal (to the process emitting the error). What this page doesnt explain is how SQLite decides that something in your process holds a lock and what conditions could lead to a false positive.

This error code occurs when you try to do two incompatible things with a database at the same time from the same database connection.

Changes related to file locking introduced in v3 and may be useful for future readers and can be found here: File Locking And Concurrency In SQLite Version 3

Leave a Reply

Your email address will not be published.