On 2007-10-24 06:03, James Briggs wrote: > Hi, > > I have been using pyodbc to connect to DB2 on an AS400. > Different beast I know but this is successful provided you have the correct > ODBC drivers installed for the flavour of DB2 on your PC. > > An example from my code, which returns a database connection: > > import pyodbc > > def connect_to_db2(): > """ > quick and dirty connect to db2 > """ > s='DRIVER={iSeries access ODBC Driver};SYSTEM=10.3.36.150;UID=%s;PWD=%s' > return > connect_to_db(connect_str=s%('myuser','mypassword'),autocommit=True) > > db=connect_to_db2() > c=db.cursor() > # > # insert working code here > # > c.close() > db.close() > > I found the autocommit needs to be true for our flavour of DB2, this may not > be the case with DB2 on AIX which has proper rollbacks and commits.
Not sure why you would need auto commit to be true. In fact, you only rarely want to *not* use transactions with a database (it's one of the most important features in database programming). You will also want to define a system data source on the machine your running the above code on, instead of passing the driver details to the Windows ODBC Manager directly. This makes your code both more portable and creates fewer issues with Windows permission management. With mxODBC you can connect to a DB2 running on AS400 using this driver for Windows: http://www-03.ibm.com/systems/i/software/access/windows/ Or this driver if you want to connect from Linux: http://www-03.ibm.com/systems/i/software/access/linux/ Both work reliably with transactions and have been in use for many years by quite a few mxODBC users. However, David was looking for a solution that runs on AIX, so all this doesn't really help him :-) Then again, mxODBC works on AIX as well... http://www.egenix.com/products/python/mxODBC/ -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Oct 24 2007) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ :::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! :::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 _______________________________________________ DB-SIG maillist - DB-SIG@python.org http://mail.python.org/mailman/listinfo/db-sig