Today is my 3rd day learning Python and despite numerous web searches I can\'t seem to get past this issue.
The code takes in input on the command line and passes it to
This is just a concatenation of two strings, so a string (the parenthesis don't matter):
('pyodbc.connect'+"('blah')")
And string % (value, value)
takes the left side string as a printf-style format string and inserts the given values in it. The result again is a string, so your conStr
is just a string. A string that probably looks like a Python function call, but a string nonetheless.
I think you want to just call pyodbc.connect()
:
con = pyodbc.connect(
'DRIVER={SQL Server};SERVER=%s;DATABASE=%s;UID=%s;PWD=%s' %
(server_name, database_name, uid, password))
Though I'm not sure about the syntax of the strint it expects as argument. At least according to this that looks about fine.