Initial writable database

4 views
Skip to first unread message

neptune2000

unread,
May 27, 2008, 5:34:57 PM5/27/08
to pldatabase
Hi. Is there an the assumption that we'll create a copy of an initial
shell, possibly partially loaded, of the database using code like the
one in the SQLiteBook (createEditableCopyOfDatabaseIfNeeded in
AppDelegate.m)?

Thanks.


Landon Fuller

unread,
May 28, 2008, 1:57:01 PM5/28/08
to pldat...@googlegroups.com


Right. We also implemented some basic database migration /
initialization support, but haven't finalized the API or decided quite
where to put it yet.
It handles schema versioning automatically -- you just implement a
migration delegate and return the new version.

Code is attached, usage would be:

YourDatabaseMigration *migration = [[[YourDatabaseMigration alloc]
init] autorelease];
PLAppDBManager *manager = [[PLAppDBManager alloc] initWithPath: path
delegate: migration];

// At this point, the database is fully initialized and all
migrations run. Open a connection:
NSObject<PLDatabase> *db = [manager openConnection];

The migration runs inside of a transaction, so any failure results in
a full rollback. We should probably at least post this on the web
site, if not merge it into the main tree.

-landonf

YourDatabaseMigration.m
YourDatabaseMigration.h
PlausibleAppDatabase.zip
PGP.sig

neptune2000

unread,
May 29, 2008, 2:46:08 PM5/29/08
to pldatabase
Excellent. Will give it a try. Thanks.

BTW, do you have any "samples" besides the 5-6 lines in the docs?

-- Marco
>  YourDatabaseMigration.m
> 1KDownload
>
>  YourDatabaseMigration.h
> 1KDownload
>
>  PlausibleAppDatabase.zip
> 24KDownload
>
>  PGP.sig
> 1KDownload

Landon Fuller

unread,
May 29, 2008, 3:02:45 PM5/29/08
to pldat...@googlegroups.com

On May 29, 2008, at 11:46 AM, neptune2000 wrote:

>
> Excellent. Will give it a try. Thanks.
>
> BTW, do you have any "samples" besides the 5-6 lines in the docs?

Other than the docs, we haven't written any official sample code. It
may be worth looking at the unit tests -- they are comprehensive and
should demonstrate how to use all parts of the system.

-landonf

PGP.sig

neptune2000

unread,
May 30, 2008, 2:49:42 PM5/30/08
to pldatabase
>> may be worth looking at the unit tests --

Where do I find the "unit tests". I looked at the subversion files,
but could not find the unit tests. Please advise. Thanks.

-- Marco
>  PGP.sig
> 1KDownload

neptune2000

unread,
May 30, 2008, 6:16:58 PM5/30/08
to pldatabase
Are all files that end with "...Test.m" what you refer as "unit
tests"?

Oskar Lissheim-Boethius

unread,
Jun 12, 2008, 1:16:17 PM6/12/08
to pldatabase
Has anyone got this usable on iPhone? Non-NDA talk here of course, but
it would be helpful to link this in.


/Oskar

Charlie Groves

unread,
Jul 13, 2008, 7:09:50 PM7/13/08
to pldatabase


On May 28, 10:57 am, Landon Fuller <land...@bikemonkey.org> wrote:
> Right. We also implemented some basic database migration /  
> initialization support, but haven't finalized the API or decided quite  
> where to put it yet.
> It handles schema versioning automatically -- you just implement a  
> migration delegate and return the new version.

I just ran across a small bug in the YourDatabaseMigration.m: when it
hits CURRENT_VERSION in the switch statement, it just returns YES and
doesn't set newVersion. That means the version in the database is set
back to 0 on the second run of the migrator and that it tries to
migrate from 0 to 1 on the third run. This can be fixed by setting
new version in that case of the switch, but I feel like it actually
makes more sense to set newVersion to currentVersion in
PLAppDBManager. The new version should be assumed to be at least what
the version was coming in, and migrateDatabase's return value is
what's used to signal if the migrator was able to get the db up to an
acceptable version anyway.

Charlie

neptune2000

unread,
Jul 14, 2008, 1:18:56 PM7/14/08
to pldatabase
It compiles and links fine with the iPhone SDK. We anded up not using
it and opting to use FMDB, as the footprint is quite different.

-- Marco

On Jun 12, 10:16 am, Oskar Lissheim-Boethius <avoc...@gmail.com>
wrote:

Landon Fuller

unread,
Jul 14, 2008, 3:10:03 PM7/14/08
to neptune2000, pldat...@googlegroups.com

On Jul 14, 2008, at 10:18 AM, neptune2000 wrote:

> It compiles and links fine with the iPhone SDK. We anded up not using
> it and opting to use FMDB, as the footprint is quite different.

Resource footprint?

-landonf

PGP.sig

Landon Fuller

unread,
Jul 14, 2008, 4:02:52 PM7/14/08
to pldat...@googlegroups.com

For the record, this was referring to binary size. Unlinked,
PLDatabase 1.1 object files weigh in at 128K, and FMDB at 96K. This is
primarily due to fixed per-object file overhead. Linked into a
resulting executable, they're smaller.

We don't consider <128K in either direction to be particularly
concerning on the iPhone. I was primarily concerned this was a memory/
cpu resource consumption issue, which is something we're attentive to
and very interested in hearing about should you run into issues.

-landonf

PGP.sig
Reply all
Reply to author
Forward
0 new messages