[odb-users] SQLITE no such table : person

Gunjur Munireddy Prashanth / LOKISA Smart Energy GmbH GPrashanth at prosolartec.de
Fri Aug 23 08:21:43 EDT 2013


Hi Boris,

Thank you.  

-----Original Message-----
From: Boris Kolpackov [mailto:boris at codesynthesis.com] 
Sent: Freitag, 23. August 2013 12:51
To: Gunjur Munireddy Prashanth / LOKISA Smart Energy GmbH
Cc: odb-users at codesynthesis.com
Subject: Re: [odb-users] SQLITE no such table : person

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



-----
E-Mail ist virenfrei.
Von AVG überprüft - www.avg.de
Version: 2013.0.2904 / Virendatenbank: 3211/6600 - Ausgabedatum: 22.08.2013 



More information about the odb-users mailing list