[odb-users] create_schema deletes db tables
Per Edin
info at peredin.com
Fri Jul 5 08:58:13 EDT 2013
Have you tried NOT calling create_schema when opening an existing database?
One can assume that the schema already exists when an existing DB is opened.
/Per
On Fri, Jul 5, 2013 at 2:17 PM, Lidia Kalinovsky <lidia at lemur-soft.com>wrote:
> Hello
>
> When I try to open existing database, all existing data is deleted just
> after schema_catalog::create_schema (*db); is called.
>
> Could somebody advice ?
>
> Code is following ( create_database function provided with examples )
>
> auto_ptr<database> db (
> new odb::sqlite::database (
> databasename, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE));
>
> // 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");
> }
>
> return db;
>
> --
> Software integration and outsourcing services,
> Lemur-Soft, Giv'at Nili
> Israel, 37825
> Phone : (+972) 545748325
> Fax : (+972) 775345383
> Email : lidia at lemur-soft.com
> Web: www.lemur-soft.com
>
More information about the odb-users
mailing list