Is there a way to get the database location from sqlite3 object?

I have a bunch of sqlite db floating in my application (don't ask) and I need to be able to get the location of the dbs file. Is there any way to do this using sqlite3 object? (I.e. there is no need to store the path along db when creating db)

Bonus question: if more than one db is connected to the sqlite3 object, how can I get the rest (they were ATTACHed)?

Thanks!

+4
source share
3 answers

API Function: sqlite3_db_filename

+4
source

sqlite3 should be an opaque structure, but check the SQLite headers, you might find some undocumented fields containing the database path there.

Even if you find such a field, using it is a bad idea and will sooner or later lead to maintenance problems.

Why do you need to save the database path along with the descriptor first?

0
source

Use filemon / processmon to control which files your application / process is accessing. You will find your SQLite file.

0
source

Source: https://habr.com/ru/post/1388351/


All Articles