pyodbc connect string

L

Larry Martell

I am having a problem building a connect string for pyodbc. It works
when everything is hard coded, but if I build the connect string it
fails.

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)

Where conn_str is:

'DRIVER=FreeTDS;' 'SERVER=xx.xx.xx.xx;' 'PORT=1433;' 'DATABASE=blah;'
'UID=foo;' 'PWD=bar;'

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top