Neither DSN nor SERVER keyword supplied
The Windows ODBC Driver Manager is quite fussy about keywords in connection strings. They must be immediately followed by the equal sign, so SERVER=...
will work, but SERVER =...
will not.
Its crazy but I managed to solve it by actually passing an option: extra_params: server=WHEREYOURSERVERLIVES\DBSERVER
I am using it pyodbc on django BTW.
Must be some bug.
something like this
'ENGINE': 'sql_server.pyodbc',
'NAME': 'YOURGREATESTDATABASE',
'USER': 'YOURGREATESTUSERNAME',
'PASSWORD': 'YOURGREATESTPASSWORD',
'HOST': 'WHEREYOURSERVERLIVES\DBSERVER',
'PORT': '',
'OPTIONS': {
'driver': 'ODBC Driver 17 for SQL Server',
'extra_params': "Persist Security Info=False;server=WHEREYOURSERVERLIVES\\DBSERVER"
Try this format:
This should work
connection = pyodbc.connect("DRIVER={/opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.4.so.2.1};SERVER=%s;DATABASE=%s;UID=%s;PWD=%s"
% (server, database, username, password))