On further inspection of your code fragment, it appears you aren't really
using (extra) attached  databases, but merely specifying an alternative file
to use if the first file is not available.  Calling sqlite3_close(...) will
do the right thing, by closing the actual database that succeeded in
opening.

--andy


On 5/9/07, Jon Scully <[EMAIL PROTECTED]> wrote:

Can one attach multiple database files using C API?  The only example
I've seen is CLI-based (using ATTACH).  The Owens book seems to hint
that it's possible to do the same trick using sqlite3_open()...

Quote Pgs. 206-207:
This is more of a connection handle than a database handle since it is
possible to attach multiple databases to a single connection.
However, this connection still represents exactly one transaction
context regardless of how many databases are attached.

But no example is given.  Here's mine:

    sqlite3 *db;

    if (sqlite3_open("flash.db", &db)) {
        fprintf(stderr, "Can't open the database in the Flash file
system\n");
        exit(2);
    } else if (sqlite3_open("ram.db", &db)) {
        fprintf(stderr, "Can't open the database in the RAM-disk file
system\n");
        sqlite3_close(db);
        exit(2);
    }

Should this work?  If so, is sqlite3_close() "smart" enough to handle
this situation?  If not, how does sqlite3 (CLI) manage this feat?

Thanks.


-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]

-----------------------------------------------------------------------------


Reply via email to