[DB-SIG] Reading DB2 on AIX in Python scripts
James Briggs
jimmy.briggs at gmail.com
Wed Oct 24 06:03:00 CEST 2007
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.
James
On 10/24/07, David.Lloyd at cis.co.uk <David.Lloyd at cis.co.uk> wrote:
>
>
> Hello,
>
> I am new to Python and I am trying to work out if it is possible to use
> Python to read DB2 version 8/9 tables on an AIX server. The code will
> reside on the same server as the database.
>
> If it is possible, does anyone have any examples of connecting to a DB2
> database they could forward to me?
>
> Regards
>
> Dave Lloyd
> *************************************************************************
>
> This e-mail may contain confidential information or be privileged. It is
> intended to be read and used only by the named recipient(s). If you are not
> the intended recipient(s) please notify us immediately so that we can make
> arrangements for its return: you should not disclose the contents of this
> e-mail to any other person, or take any copies. Unless stated otherwise by
> an authorised individual, nothing contained in this e-mail is intended to
> create binding legal obligations between us and opinions expressed are those
> of the individual author.
>
> The CIS marketing group, members of which are authorised and regulated by
> the Financial Services Authority, includes:
> Co-operative Insurance Society Limited Registered in England number 3615R
> CIS General Insurance Limited Registered in England number 29999R
> CIS Unit Managers Limited Registered in England and Wales number 2369965
> CIS Policyholder Services Limited Registered in England and Wales number
> 3390839
>
> Registered offices: Miller Street, Manchester M60 0AL
> Internet http://www.cis.co.uk
>
>
> CIS & the CIS logo (R) Co-operative Insurance Society Limited
>
>
> *************************************************************************
> _______________________________________________
> DB-SIG maillist - DB-SIG at python.org
> http://mail.python.org/mailman/listinfo/db-sig
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/db-sig/attachments/20071024/a87b1bde/attachment.htm
More information about the DB-SIG
mailing list