Hi, I am using "sqlite3_deserialize" to read a database. sqlite3_deserialize API returns SQLITE_OK. But the "sqlite3_prepare_v2" API fails with error "no such table: moz_annos". I am adding a sample code fragment below. "dbBuffer" varibale is used to hold the database content and it contains exactly what is contained in the test db file. I also verified the query and it works from "SQLite" shell. The DB is of 5MB size. I have tested with another small sized db (100KB, entirely different tables) and the code works fine. Any hint on a possible cause of this error?
char *dbBuffer = new char[BufferSize]; ifstream ifs; ifs.open(filename, std::ifstream::in | std::ifstream::binary); if (!ifs.is_open()) throw std::exception("file open error"); ifs.read(dbBuffer, BufferSize); if(ifs.gcount()!= BufferSize) throw std::exception("couldn't read full data"); sqlite3 *dbHandle=nullptr; if (sqlite3_open(":memory:", &dbHandle) != SQLITE_OK) throw std::exception("sqlite3 memory db open failed"); int RetSqlite = sqlite3_deserialize(dbHandle, "main", (unsigned char*)dbBuffer, BufferSize, BufferSize, SQLITE_DESERIALIZE_READONLY); if (RetSqlite != SQLITE_OK) throw std::exception("sqlite3 db open fialed"); sqlite3_stmt *statement = nullptr; string Query = "select content,dateAdded,lastModified FROM moz_annos"; if (sqlite3_prepare_v2(dbHandle, Query.c_str(), Query.length(), &statement, 0) != SQLITE_OK) throw std::exception("sqlite3 prepare failed"); Thanks, Lloyd _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users