configuring ODBC DSN with a python script

Andy Robinson andy at
Thu Feb 5 02:22:16 CET 2004

On 4 Feb 2004 11:09:52 -0800, jani at (Jani Yusef) wrote:

>I am building an application which, unfortunately, *must* use an
>access db. The users will have the relevane mdb file installed on
>their system. As part of the installer. Now, the part I am stuck on is
>how do I configure the ODBC dsn without having the user open up the
>ODBC control panel which will in all honestly just scare and confuse
>them. ;)
>Has anyone approached this problem before? What did you do?

Most drivers let you pass this in at runtime by building a string with
a number of key/value parameters.  With Access, the magic one
is Dbq which refers to the file name.  This works for me....

>>> import mx.ODBC.Windows
>>> dc = mx.ODBC.Windows.DriverConnect
>>> conn = dc("Driver={Microsoft Access Driver
>>> cur = conn.cursor()
>>> cur.execute('select count(*) from Codes')
>>> cur.fetchall()

- Andy Robinson

p.s. Steve Holden tipped me of

More information about the Python-list mailing list