How can I count the number of open connections in an sqlite database?
An open file monitor like lsof
will do it
lsof dbName.sql
will give you list of connection
OpenerName 6158 User 39u REG 1,2 20480 20397113 dbName.sql
According to these posts on the mailing list there is no way to check the number of open connections through code or the database itself. There is no API.
According to this post, if you are running on a POSIX type system you can use the lsof
command to count how many processes have opened the database.
If you are on Windows you can use Process Explorer to count the number of connections with the following steps:
- In Process Explorer click on 'Find' -> Find Handle or DLL...
- Type in the name of your sqlite database and click on 'Search' (or hit Enter)
- In the results window, click on your database. It will become highlighted as a 'file' in the main Process Explorer window.
- Back in the main window, right-click on your database file and click Properties
- You can now see the number of References and Handles