SQLite Forum

V3.36
Login
Your question doesn't quite correspond with how SQLite manages open databases.  When you want SQLite to access a database you create a 'connection'. That database will be the 'main' database for that connection.  If you want SQLite to access a second database you can either attach another database to the first connection, or open another connection.  So …

One instance of SQLite can have many connections.  Each connection has a main database and can have many attached databases.

Given the above, to discover all databases you currently have access to, for each SQLite connection, use

<https://sqlite.org/pragma.html#pragma_database_list>

<code>    PRAGMA database_list</code>

It returns one line per database, second column is the connection's name for that database, third column is the name of the database file.

Your next natural question is how to find out what tables are in each of those databases, and you'll find it on the above page, under

<code>    PRAGMA schema.table_xinfo(table-name)</code>

(I spend a few minutes trying to find out how to iterate through the connections for an instance of SQLite and failed.  Contributions welcome.)