ctree data
Terry Reedy
tjreedy at udel.edu
Sat May 12 19:32:34 EDT 2007
"Carl K" <carl at personnelware.com> wrote in message
news:r4idnSn4-LNhttvbnZ2dnUVZ_uWlnZ2d at comcast.com...
|A friend needs to convert c-tree plus data to MySql. I can to the "to
MySql
| part, but need some help with the "from c-tree." If I just wanted to get
this
| done, I would hunt down the ODBC driver and use some MSy thing. But I am
trying
| to hone my Python skills,
| My searching around has come up with a few ways to use Python to read the
data:
|
| 1. pull what I need from some other py code that uses c-tree:
|
|
http://oltp-platform.cvs.sourceforge.net/oltp-platform/OLTPP/services/PythonScript/PythonTranslate.h?view=markup
|
http://oltp-platform.cvs.sourceforge.net/oltp-platform/OLTPP/scripts/TestZipCodes.py?view=markup
|
| 12 a,b,c = ZipCode.Get()
| 13 print "Zip code is ", a
| 14 print "State is ", b
| 15 print "City is ", c
|
| I am sure this is what I want. I just haven't figured out where to
start.
|
| 2. "Pyrex" to create Python bindings to C API with minimal C knowledge.
I took
| C and did a few little utilities on my own in the 90's. plus I can make
a
| tarball. today I am not sure I even qualify for "minimal."
|
| 3. the C API is present as a shared object (.so), use it from Python with
| ctypes. I have no idea what that means.
[snip]
I personally would start with either 1 or 3, but probably 3 since the skill
of using ctypes is transferable to other problems and I want to learn it
anyway. Ctypes is a foreign function interface (FFI) module. It is new in
the Python stdlib with 2.5 but has been around as a 3rd party module much
longer. With a specification of the C API in hand, you should be able to
write Python functions that call functions in the shared library. Ctypes
handles the interconversion of Python and C datatypes and the calling
details.
I would start with the simplest thing that you can verify working: open
database, get some info that you can print, so you know you really opened
it, and close database.
Terry Jan Reedy
More information about the Python-list
mailing list