lundi 17 août 2015

Sqlite c++ ATTACH memory database

I try to attach in memory db to an existing db connection via c++ api like this:

void InMemoryDbtest(){
    sqlite3 *db;
    int rc = sqlite3_open("E:/VS_workspace/ConsoleSQLITE/Debug/TPCH.sqlite", &db);
    if (rc){
        cout << "nie moge otworzyc bazy danych ";}
    else{
        cout << "otwarcie bazy ---- udalo sie\n";}
    char *err;

sqlite3_exec(db, "ATTACH DATABASE 'file::memory:?cache=shared' as pom",0,0,&err);

    cout << "error" << err << endl;
    string q = "create table pom.bla as select n_name from NATION ";
    sqlite3_exec(db, q.c_str(), 0, 0, &err);
    cout << "error" << err << endl;
}

I get 2 error messages"

unable to open database: file:memory and unknown database pom

Any ideas? When i try to attach db in sqlite console everything works just fine

Aucun commentaire:

Enregistrer un commentaire