From the comments around the attach function, you'd have to execute a SQL
statement "attach database x as y KEY z".  I assume that 'key Z' is for the
encrypting version of SQLite3 distributed by drh.

/*
** An SQL user-function registered to do the work of an ATTACH statement.
The
** three arguments to the function come directly from an attach statement:
**
**     ATTACH DATABASE x AS y KEY z
**
**     SELECT sqlite_attach(x, y, z)
**
** If the optional "KEY z" syntax is omitted, an SQL NULL is passed as the
** third argument.
*/

--a


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