mxODBC ...Driver Connect DNS_string....

Amir Mistric amir.mistric at usa.net
Tue Aug 1 15:42:52 EDT 2000


Hi
I have mxODBC interface to the IBM DB2 via unixODBC manager (AIX 4.3.3-
RS/6000)....I can nicely connect to my database via Connect method
but ConnectDriver is givving me problems. I am trying to figure out how
should "DSN_string" look like in following snippet...
(Note that commented line with Connect works but one below ConnectDriver
does not...)
I have tried about 26 different possibilites with no luck:((((((

#!/usr/local/bin/python -O

import mxDateTime
import mxODBC

#db = mxODBC.Connect('SAMPLE','db2inst1','ibmdb2')
db = mxODBC.DriverConnect('SAMPLE;db2inst1;ibmdb2')
c = db.cursor()
c.execute('SELECT COUNT(*) FROM EMPLOYEE')
emp_cnt = c.fetchone()
print emp_cnt
c.close()
db.close()


I read the manual and this is what it says....
DriverConnect(DSN_string[,clear_auto_commit=1])
This constructor returns a connection object for the given datasource which
is managed by an ODBC Driver Manager (e.g. the Windows ODBC Manager or
iODBC). It allows passing more information to the database than the standard
Connect() constructor.

Please refer to the ODBC manuals of your ODBC manager and database for the
exact syntax of the DSN_string. It typically has these entries:
'DSN=datasource_name;UID=userid;PWD=password;' (case is important !). See
Connect() for comments on clear_auto_commit.

Note that this API is only available if the interface was compiled with
HAVE_SQLDriverConnect switch defined. See the subpackages section and the
subpackage's Setup file for details.



If anyone knows how this should be formatted let me know....

Thanks

Amir







More information about the Python-list mailing list