[DB-SIG] Simple? ODBC connection issue

Peter Machell peter at machell.net
Fri Oct 17 02:55:32 CEST 2008


I'm using pyodbc to connect to several databases.

On one of them, the database password needs to be a variable.

If I hard code the password, the connection works fine:

cnxn = pyodbc.connect("DSN=test;UID=test;PWD=test")

However substituting a variable fails:

passwd='test'
connectstring='pyodbc.connect("DSN=test;UID=test;PWD='+passwd+'")'
cnxn = connectstring

I get an ODBC login failed error.

Sorry if I'm just having a Friday brain problem but I just can't get  
this to work, can anyone help?

regards,
Peter.


More information about the DB-SIG mailing list