accessing fields in the database outside of *pedia

Any trouble you encounter with the Pedias, here's the place to ask for help.
Post Reply
josephabennett99
Contributor
Contributor
Posts: 6
Joined: Mon Dec 28, 2009 11:34 am

accessing fields in the database outside of *pedia

Post by josephabennett99 »

I would like to access the database of the *Pedias outside of the GUI. I'm talking about the "Database.pediadata" file that is stored in the Library/Applications Data/???pedia directory.

I know this is an sqlite3 database, and most of the fields in the tables are simple text fields, so most accesses are fine. However, in some tables, the ZCOLLECTIONS table in particular, there are a couple of BLOBs. One of them looks to be a BLOB for a Cocoa object that I'm guessing holds the information needed to create and maintain a "Smart Collection".

Is Bruji comfortable sharing this information with any 3rd parties that might want to develop utilities on top of the *pedias?
User avatar
Conor
Top Dog
Posts: 5346
Joined: Sat Jul 03, 2004 12:58 pm
Contact:

Re: accessing fields in the database outside of *pedia

Post by Conor »

We are comfortable sharing the information, we want the data to be as open as can be. You are correct that they few BLOB objects are internal information that was easier to store that way. For example the smart collection rules your trying to access are stored as NSPredicates (this way we can use them directly in Core Data without any translation). To read them outside of the Pedias you will have to still use Cocoa to make things simple. The code you would need is as follows:

Code: Select all

NSData * theBLOBvalue = Add the raw value of the BLOB here.
if (theBLOBvalue) {
      NSPredicate *aPredicate = [NSKeyedUnarchiver unarchiveObjectWithData: theBLOBvalue];
}

Then with the NSPredicate you could ask it for predicateFormat and get the actual rules in English. However, without Cocoa I am not sure how you would go about translating the raw binary that is stored in the BLOB, since as you can see we let Cocoa take care of that.

If your looking to add functionality into the Pedias consider our plug-in architecturethat might fit your needs.
Post Reply