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.
_______________________________________________
DB-SIG maillist  -  DB-SIG@python.org
http://mail.python.org/mailman/listinfo/db-sig

Reply via email to