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

django-pyodbc-azure login string not working with MS SQL Server 16 #136

Closed eddy-ojb closed 6 years ago

eddy-ojb commented 6 years ago

I am struggling to get this library to communicate with MS SQL Server 16 in Django. I followed the instructions laid out in the documentation and consistently receive an error (see end of post) .

We receive this error when using a DSN or username and password combo. We know that the connection works when using pyodbc to connect to the server and database, as we can get it to print out information from it. We also know that the Windows systems ODBC connector is working.

What also appears to work is to use this library with Django and to connect to the database without stating a database name in the 'NAME' variable.

Again, we know that the credentials have been setup appropriately in the database since pyodbc can connect by itself.

Is anyone able to shed any light on what we might be doing incorrect or lines of enquiry?

We are using: Windows Server 2016 Standard Python 3.6 (via Anaconda) Django-2.0.1 pyodbc-4.0.22 django_pyodbc_azure-2.0.1.0

our database string is something like:

DATABASES = { 'default': { "ENGINE": "sql_server.pyodbc", "HOST": "sql_address\INST1", "DSN" : "SQL_DEV_13", "NAME": "MDS", 'OPTIONS': { 'driver': 'ODBC Driver 13 for SQL Server' } } }

The error is:

django.db.utils.InterfaceError: ('28000', '[28000] [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Login failed for user \'DEV\A2236-3\'. (18456) (SQLDriverConnect); [28000] [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Cannot open database "MDS" requested by the login. The login failed. (4060); [28000] [Microsoft][ODBC Driver 13 for SQL Server]Invalid connection string attribute (0); [28000] [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Login failed for user \'DEV\A2236-3\'. (18456); [28000] [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Cannot open database "MDS" requested by the login. The login failed. (4060); [28000] [Microsoft][ODBC Driver 13 for SQL Server]Invalid connection string attribute (0)')

eddy-ojb commented 6 years ago

Our issue was with SQL server, little did we know that behind the scenes there was some funny admin settings.

wdifruscio commented 5 years ago

Hi there! What admin settings, if you remember :(