To connect without requiring a DSN, specify the driver and connection
information:
DRIVER={SQL Server};SERVER=localhost;DATABASE=testdb;UID=user;PWD=password
Note the use of braces when a value contains spaces.
But, when following the default instructions, the connstr is:
'DRIVER=ODBC Driver 13 for SQL Server;SERVER=myserver.database.windows.net;UID=user@myserver;PWD=password;DATABASE=mydb;MARS_Connection=yes'
Note the lack of braces!
If I add them myself in the driver...
'OPTIONS': {
'driver': '{ODBC Driver 13 for SQL Server}',
},
I get...
'DRIVER={{ODBC Driver 13 for SQL Server}}};SERVERNAME=myserver.database.windows.net;UID=user@myserver;PWD=password;DATABASE=mydb'
Note that there are now 2 braces to begin and 3(!) to end. Could this explain why I can't connect with version 2.1.0.0?
Looking at the docstring for pyodbc.connect():
But, when following the default instructions, the connstr is:
'DRIVER=ODBC Driver 13 for SQL Server;SERVER=myserver.database.windows.net;UID=user@myserver;PWD=password;DATABASE=mydb;MARS_Connection=yes'
Note the lack of braces!
If I add them myself in the driver...
I get...
'DRIVER={{ODBC Driver 13 for SQL Server}}};SERVERNAME=myserver.database.windows.net;UID=user@myserver;PWD=password;DATABASE=mydb'
Note that there are now 2 braces to begin and 3(!) to end. Could this explain why I can't connect with version 2.1.0.0?