Accessing DB2 with Python

S

Shawn Milo

Is anyone doing this? I would like to access a DB2 database (IBM's database)
with Python. I checked "Python in a Nutshell," and it refers to
ftp://people.linuxkorea.co.kr/pub/db2, but I am unable to connect
to that site, although it could be a firewall issue, as I am at work.

Is there any commonly used module for this?

Thanks,
Shawn
 
L

Larry Bates

I just tried the link at it works from here. Site has
source and Windows binary versions of software. Looks
loke it is being maintained. Windows binary for Python
2.3 was added in September 2004. No 2.4 binary.

Larry Bates
Syscon, Inc.
 
J

Jan Dries

Shawn said:
Is anyone doing this? I would like to access a DB2 database (IBM's
database)
with Python. I checked "Python in a Nutshell," and it refers to
ftp://people.linuxkorea.co.kr/pub/db2, but I am unable to connect to
that site, although it could be a firewall issue, as I am at work.

Is there any commonly used module for this?

You could try mxODBC. It has support for DB2. You can find it at:
http://www.egenix.com/files/python/mxODBC.html
You can download it for free and use it for a 30 day evaluation period.
After that, you must pay for a commercial license.

Regards,
Jan
 
J

Jarek Zgoda

Larry said:
I just tried the link at it works from here. Site has
source and Windows binary versions of software. Looks
loke it is being maintained. Windows binary for Python
2.3 was added in September 2004. No 2.4 binary.

Be aware, that it's a module for "normal" DB2, not a DB2/400. To access
DB2/400 you have to use ClientAccess ODBC (from Windows or *nix
platform) driver or iSeries port of Python (from AS/400).
 
G

Grumman

Jarek said:
Be aware, that it's a module for "normal" DB2, not a DB2/400. To access
DB2/400 you have to use ClientAccess ODBC (from Windows or *nix
platform) driver or iSeries port of Python (from AS/400).


And just to be complete, under windows, using win32all, you can also use
the OLE DB driver supplied with ClientAccess (IBMDA400), which offers
some improvements over plain ODBC.

Its been a long time since I did this, but it was *very* simple. I
could probably dig up an example or two if necessary.

Connection string basically looks like:
Provider=IBMDA400;User ID=USERNAME;Password=PASSWORD;Initial
Catalog=DATABASE_NAME;Data
Source=AS_400_SERVER_NAME

Provider,User ID, Password, and Data Source are required. Data Source
can be either an IP address, or a DNS defined hostname. I've never
bothered with 'Initial Catalog', but it would be one of the database
names visible via WRKDBR. (Usually defaults to the default system name,
which is shipped set to the system serial#)

Optionally, you can add 'Catalog Library List=Lib1 Lib2 Lib3' to add
additional libraries to the current library list for the connection.

Last I knew, there were a few methods exposed by ADO that weren't
supported via this driver, but like I said, its been a long time.

I'm sure there's a pretty complete python ADO wrapper out there as well.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top