How to lock sqlite database?

We had problems in the past when the rogue process contained sqlite db lock. I wrote a code to notify us if this happens, but I need to check it.

How can I intentionally lock the sqlite database so that I can verify that I can check if it is locked?

+6
source share
1 answer

Perform the following operations:

PRAGMA locking_mode = EXCLUSIVE; BEGIN EXCLUSIVE; 

This will lock the entire database until you complete:

 COMMIT; 

For simplicity, you can do this with the sqlite3 command line sqlite3 .

See the documentation for more information.

+5
source

All Articles