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:

  1. In Process Explorer click on 'Find' -> Find Handle or DLL...
  2. Type in the name of your sqlite database and click on 'Search' (or hit Enter)
  3. In the results window, click on your database. It will become highlighted as a 'file' in the main Process Explorer window.
  4. Back in the main window, right-click on your database file and click Properties
  5. You can now see the number of References and Handles