[DB-SIG] Simple? ODBC connection issue
Vernon Cole
vernondcole at gmail.com
Fri Oct 17 04:39:54 CEST 2008
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 <Chris.Clark at ingres.com> 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 at python.org
> http://mail.python.org/mailman/listinfo/db-sig
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/db-sig/attachments/20081016/cae1089c/attachment.htm>
More information about the DB-SIG
mailing list