Perl to Python

Gillou nospam at bigfoot.com
Tue Nov 27 07:11:21 EST 2001


You should consider to use a python DB API 2.0 compliant service to handle
your OpenLink connection.
I'm sure that a package like mxODBC (said to support any OpenLink driver)
will shorten your code significantly...
http://www.lemburg.com/files/python/
It's a commercial package but you can use it for free in a non commercial
environment.

Querying your database is just easy as...

import ...
mycnx = mxODBC.connect(host='myhost', database='mydb', user='me',
password='xxx')
crs = mycnx.cursor()
crs.execute('select id from mytable where name='bob')
bobid = crs.fetchone()[0][0]

This is a more "pythonic" way to do the job an changing your database to
something else (say MySQL on your local host) will require few change.

HTH

--Gillou






More information about the Python-list mailing list