[odb-users] SQLITE no such table : person

Boris Kolpackov boris at codesynthesis.com
Fri Aug 23 06:51:19 EDT 2013


Hi Gunjur,

>From your main.cxx:

> auto_ptr<database> db (
>   new odb::sqlite::database (
>     "test.db", SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE));

You have modified the example not to use the create_database()
helper function (defined in database.hxx) but instead create
the SQLite database directly. If you look into the implementation
of create_database(), you will see that for SQLite, besides
creating the database, it also creates the schema (i.e., tables
necessary to store the persistent objects). Here is the relevant
code fragment:


>   // Create the database schema. Due to bugs in SQLite foreign key
>   // support for DDL statements, we need to temporarily disable
>   // foreign keys.
>   //
> 
>   {
>     connection_ptr c (db->connection ());
> 
>     c->execute ("PRAGMA foreign_keys=OFF");
> 
>     transaction t (c->begin ());
>     schema_catalog::create_schema (*db);
>     t.commit ();
> 
>     c->execute ("PRAGMA foreign_keys=ON");
>   }

If you add this to your main.cxx, then everything should work fine.

Boris



More information about the odb-users mailing list