1)Is there a pragma or any way to know the current lock state of sqlite db?.
2)Also, Is there a way to know if any other process is using the DB?.
No pragma, but the FAQ states:
When SQLite tries to access a file that is locked by another process, the default behavior is to return SQLITE_BUSY.
However, that only means the database is locked for writing, not reading.
Regarding #1: No, because the answer you got would be immediately stale (that is if you got an answer of "no the database isn't locked", someone else could come along and immediately lock it, leaving you with bad info).
The correct approach is to simply try your operation (optionally with a timeout) and see if it succeeds.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With