How to find out sqlite DB lock status?

1) Is there a pragma or some way to find out the current lock state in sqlite db ?.
2) Is there also a way to find out if any other database process is using ?.

+4
source share
2 answers

There is no pragma, but the FAQ says:

When SQLite tries to access a file that is locked by another process, the default behavior is to return SQLITE_BUSY.

However, this means that the database is locked for writing, not reading.

+2
source

Regarding # 1: No, because the answer you have will be immediately outdated (that is, if you have the answer “no database is locked”, someone else may come and immediately block it, leaving you bad information).

The right approach is to simply try your operation (optionally with a timeout) and see if it succeeds.

+1
source

Source: https://habr.com/ru/post/1334698/


All Articles