Embed Python and Database in my C program
Martin von Loewis
loewis at informatik.hu-berlin.de
Mon Feb 14 16:28:11 CET 2000
"Warren Postma" <embed at geocities.com> writes:
> I need a simple DB engine for a C program that can be easily accessed from
> both Python and C. Does anyone have any suggestions? The platforms are WinNT
> and an embedded realtime Win32 variant called "Phar Lap Realtime ETS
If ODBC is available on your target systems, and if the ODBC-supported
databases qualify as 'simple', I guess you could use ODBC from both C
and Python. In C, you wouldn't use the Python wrapper code, but the
native ODBC functions directly.
Another alternative is to use Berkeley DB, which also has a C
interface, and the bsddb module around it. BSD DB also runs on
> It looks like the "shelve" part of Python creates a binary on-disk
> dictionary. If that's so, and you can interate through a rowset and
> look up on a single key, I could live with that.
Shelve is implemented on top of anydbm and pickle. anydbm in turn is
implemented on top of bsd db (if available). bsddb provides a
persistens string->string dictionary, so if you only need to store
strings, bsd db should work fine.
If you need to store objects of varying type, you'll have to use
shelve. Of course, to access a shelve from C, you'll have to do a lot
of PyObject_CallMethod calls.
Hope this helps,
More information about the Python-list