michiya / django-pyodbc-azure

Django backend for Microsoft SQL Server and Azure SQL Database using pyodbc
https://pypi.python.org/pypi/django-pyodbc-azure
BSD 3-Clause "New" or "Revised" License
321 stars 140 forks source link

connstr format error? #181

Open richardbrockie opened 6 years ago

richardbrockie commented 6 years ago

Looking at the docstring for pyodbc.connect():

    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?