Hi,

I am trying to attach an in-memory database and then create a table in
it. Here is the code that I am using:

/* I have already opened a connection to a database before the following */
sqlite3_exec(db, "ATTACH DATABASE :memory AS metadb", NULL, NULL, &errmsg);
        if (errmsg != NULL) {
                warnx("%s", errmsg);
                free(errmsg);
                exit(EXIT_FAILURE);
        }

/* I need to keep all the operations in a single transaction for
better performance */
sqlite3_exec(db, "BEGIN", NULL, NULL, &errmsg);
        if (errmsg != NULL) {
                warnx("%s", errmsg);
                free(errmsg);
                exit(EXIT_FAILURE);
        }

...
/* somewhere down the line I try to create a table in the in-memory
attached database */
sqlstr = "CREATE TABLE IF NOT EXISTS metadb.file_cache("
                        " md5_hash, file PRIMARY KEY)";
                        

sqlite3_exec(db, sqlstr, NULL, NULL, &errmsg);
if (errmsg != NULL) {
        warnx("%s", errmsg);
        free(errmsg);
        exit(EXIT_FAILURE);
}
...

But on running the program I am getting an error exactly at the point
where I am trying to execute the create table statement above:

# ./makemandb
Building temporary file cache
makemandb: near ".": syntax error

What might be wrong here ? From the documentation it seems that I
should be explicitly specifying the database name if I have attached
one or more databases.

Thanks
Abhinav
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to