4

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?

1
  • 1
    Which SQLite client library are you using, and for what language? Commented Jan 15, 2020 at 19:55

1 Answer 1

5

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.