pyodbc with DB2 on Windows 2008

35 views
Skip to first unread message

bansi

unread,
Dec 13, 2010, 5:04:56 PM12/13/10
to pyodbc
I have downloaded Python 2.7 (python-2.7.1.amd64.msi) and then python
extension module for DB2 database (i.e. pyodbc-2.1.8.win-amd64-
py2.7.exe) which extracted following files to the folder C:
\Python2.7\Lib\site=packages

-pyodbc.pyd
-pyodbc-2.1.8-py2.7.egg-info

Now i am not sure how to write a sample program to connect to DB2
database. I searched extensively on Google and on these forums and
found following snippet. Please make necessary corrections or provide
complete example as i plan to use it with Splunk (http://
www.splunk.com/)

import csv
import pyodbc
conn =
pyodbc.connect("Driver={db2ODBC};Database=TEST001;Hostname=db2server;Port=5­
0001;Protocol=TC

PIP;Uid=username;Pwd=password;",
autocommit = True , ansi = True)
curs = conn.cursor()
curs.execute('select count(edokimp_id) from edokimp')
print curs.fetchall()

Wondering if i need to separately download db2ODBC driver
Reply all
Reply to author
Forward
0 new messages