SQLite Forum

Identifying attached database
Login
There is no C API to directly enumerate the list of "schema" names recognized by a connection.

There is, however, a pragma (SQL Query) to retrieve this information.  You may either execute **PRAGMA database_list;** or **SELECT * FROM pragma_database_list;** to retrieve information about the schema's available in a connection.  (As long as the version of SQLite3 you are using supports this introspection pragma and it has been either enabled or not disabled as is appropriate for that version).

```
>sqlite
-- Loading resources from C:\Users\KMedcalf/.sqliterc
SQLite version 3.34.0 2020-10-05 19:05:20
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> pragma database_list;
┌─────┬──────┬────────────────────────┐
│ seq │ name │          file          │
├─────┼──────┼────────────────────────┤
│ 0   │ main │                        │
│ 1   │ temp │                        │
│ 2   │ _tz_ │ d:\source\sqlite\tz.db │
└─────┴──────┴────────────────────────┘
sqlite> select * from pragma_database_list;
┌─────┬──────┬────────────────────────┐
│ seq │ name │          file          │
├─────┼──────┼────────────────────────┤
│ 0   │ main │                        │
│ 1   │ temp │                        │
│ 2   │ _tz_ │ d:\source\sqlite\tz.db │
└─────┴──────┴────────────────────────┘
sqlite>
```