[odb-users] Opening an already existing database (SQLite) and appending

Szumowski, Thomas thomas.szumowski at lmco.com
Wed Jun 29 12:12:18 EDT 2011


I attached a small test case that is derived from the "hello" example. See the top of driver.cxx for usage. Essentially I first persist John Doe. It shows up in the database xyz.sql. I then run the program again persisting Jane Doe. But when I look at xyz.sql again, it only shows Jane, and not both John and Jane.

-Tom

________________________________________
From: Boris Kolpackov [boris at codesynthesis.com]
Sent: Wednesday, June 29, 2011 8:32 AM
To: Szumowski, Thomas
Cc: odb-users at codesynthesis.com
Subject: EXTERNAL: Re: [odb-users] Opening an already existing database (SQLite) and    appending

Hi Thomas,

Szumowski, Thomas <thomas.szumowski at lmco.com> writes:

> I also tried the database constructor that takes in a name and flags -
> something to the effect "database(string name, int flags)", setting
> the flags to SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, with no luck.

According to the SQLite documentation[1], opening with just
SQLITE_OPEN_READWRITE will open the existing database but fail if it does
not already exist. Opening with SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE
will create the database if it does not exist. ODB underneath always uses
the sqlite3_open_v2() function.

So it sounds to me that this should work as expected. Can you elaborate
on the overwrite behavior that you are observing? Is the database always
empty after you open it even though you stored something into it before?
Can you also check that you are actually committing the transaction? If
none of this helps, can you send a small test case that reproduces this?

[1] http://www.sqlite.org/c3ref/open.html

Boris
-------------- next part --------------
A non-text attachment was scrubbed...
Name: db_append_test.zip.allow
Type: application/octet-stream
Size: 10570 bytes
Desc: db_append_test.zip.allow
Url : http://codesynthesis.com/pipermail/odb-users/attachments/20110629/eb6eae22/db_append_test.zip.obj


More information about the odb-users mailing list