tags:

views:

341

answers:

2

I am working on integrating with several music players. At the moment my favorite is exaile.

In the new version they are migrating the database format from SQLite3 to an internal Pickle format. I wanted to know if there is a way to access pickle format files without having to reverse engineer the format by hand.

I know there is the cPickle python module, but I am unaware if it is callable directly from C.

+1  A: 

You can embed a Python interpreter in a C program, but I think that the easiest solution is to write a Python script that converts "pickles" in another format, e.g. an SQLite database.

Cristian Ciupitu
+2  A: 

Like Cristian told, you can rather easily embed python code to you C code, see example here: http://docs.python.org/extending/extending.html#calling-python-functions-from-c

Using cPickle is dead easy as well on python you could use somehting like:

import cPickle

f = open('dbfile', 'rb')
db = cPicle.load(f)
f.close()
# handle db integration
f = open('dbfile', 'wb')
cPickle.dump(db, f)
f.close()
hhurtta
as far as I can tell and as far as I've been told the only option is to embed a python interpreter. Since I won't need to port it to win32, this isn't such a bad solution.
Phillip Whelan