Chris is correct.

> passwd='test'
> connectstring="DSN=test;UID=test;PWD=%s"
> cnxn = pyodbc.connect(connectstring % passwd)
>
is much more readable.
--
Vernon

On Thu, Oct 16, 2008 at 7:21 PM, Chris Clark <[EMAIL PROTECTED]> wrote:

> On 10/16/2008 5:55 PM, Peter Machell wrote:
>
>> ...If I hard code the password, the connection works fine:
>>
>> cnxn = pyodbc.connect("DSN=test;UID=test;PWD=test")
>>
>> However substituting a variable fails:
>>
>>
>> ...
>>
>
>
> Try printing the string to screen first :-)
>
> You have single quotes embedded in the variables based so the variable is
> never in place. Use % markers instead and make your life easier :-)
>
>
>
>
> _______________________________________________
> DB-SIG maillist  -  DB-SIG@python.org
> http://mail.python.org/mailman/listinfo/db-sig
>
_______________________________________________
DB-SIG maillist  -  DB-SIG@python.org
http://mail.python.org/mailman/listinfo/db-sig

Reply via email to