SQLite Forum

Can I get the file name of a temporary on-disk database?
Login
The docs for sqlite3_open state this: 

> If the filename is an empty string, then a private, temporary on-disk database will be created. This private database will be automatically deleted as soon as the database connection is closed.

Is there any way to get the name of the file that is created? I need it for a subsequent ATTACH DATABASE statement, but I can't see any way of getting it.

Creating my own temporary file so that I know the name of it (via mkstemp) doesn't work because a) Even though it's empty, it won't be an SQLite database file, so can't be passed to sqlite3_open, and b) To address a), I could delete the file that mkstemp creates and then pass the name of it to sqlite3_open to create a database with that file name, but of course that creates a gap between when msktemp generated the file name, and when SQLite actually creates a database with that name, and that eliminates the guarantee that the file name generated by mkstemp is uniquely available for the process to use. The risk of this might be small, but is something to be avoided if possible.

Any help on this would be greatly appreciated. 

Thanks,

Tim