Reputation: 1491
I have an handler for a connection to an sqlite3 database. I would like to know if the database is an in-memory database or not.
Is there any API to do so?
Upvotes: 4
Views: 855
Reputation: 164919
At the C API layer you can use sqlite3_db_filename
to get the filename. If it's NULL or empty you've got a temporary or in-memory database.
The sqlite3_db_filename(D,N) interface returns a pointer to a filename associated with database N of connection D. The main database file has the name "main". If there is no attached database N on the database connection D, or if database N is a temporary or in-memory database, then this function will return either a NULL pointer or an empty string.
Whatever client API library you're using likely acts the same: the filename will be empty.
Upvotes: 5