Accessing DB2 with Python

Grumman grumman at example.com
Thu Dec 16 20:20:09 EST 2004


Jarek Zgoda wrote:
> 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.



More information about the Python-list mailing list