Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #70753 > unrolled thread

Re: pyodbc connect string

Started byLarry Martell <larry.martell@gmail.com>
First post2014-04-29 19:15 -0600
Last post2014-04-29 19:15 -0600
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: pyodbc connect string Larry Martell <larry.martell@gmail.com> - 2014-04-29 19:15 -0600

#70753 — Re: pyodbc connect string

FromLarry Martell <larry.martell@gmail.com>
Date2014-04-29 19:15 -0600
SubjectRe: pyodbc connect string
Message-ID<mailman.9600.1398820519.18130.python-list@python.org>
On Tue, Apr 29, 2014 at 7:09 PM, Chris Angelico <rosuav@gmail.com> wrote:
> On Wed, Apr 30, 2014 at 10:57 AM, Larry Martell <larry.martell@gmail.com> wrote:
>> This works:
>>
>> pyodbc.connect('DRIVER=FreeTDS;' 'SERVER=xx.xx.xx.xx;' 'PORT=1433;'
>> 'DATABASE=blah;' 'UID=foo;' 'PWD=bar;')
>>
>> But this does not:
>>
>> pyodbc.connect(conn_str)
>>
>> conn_str is constructed with:
>>
>>  conn_str = "'DRIVER=%s;' 'SERVER=%s;' 'PORT=%s;' 'DATABASE=%s;'
>> 'UID=%s;' 'PWD=%s;'" \
>>                 % (RECIPE_DB['DRIVER'], RECIPE_DB['SERVER'],
>> RECIPE_DB['PORT'], RECIPE_DB['DATABASE'],
>>                    RECIPE_DB['USER'], RECIPE_DB['PASSWORD'])
>>
>> Anyone have any ideas as to why this doesn't work.
>
> Start by printing out conn_str. That'll tell you if it's actually
> coming out the way you think it is. I can see where the problem
> probably is (assuming these are faithful copy/pastes), in the form of
> an extra double quote; but actually print them out and see what you're
> getting.

When I print conn_str out it does not have the double quotes, But I
was able to solve this by doing this:

 pyodbc.connect('DRIVER=' + RECIPE_DB['DRIVER'] + ';' + 'SERVER=' +
RECIPE_DB['SERVER'] + ';' + 'PORT=' + RECIPE_DB['PORT'] + ';' +
'DATABASE=' + RECIPE_DB['DATABASE'] + ';' + 'UID=' + RECIPE_DB['USER']
+ ';' + 'PWD=' +  RECIPE_DB['PASSWORD'] + ';')

'
Thanks.

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web