0

I am struggling with connecting to my local MsSQL server with Django. It says when I make command 'makemigrations':

django.core.exceptions.ImproperlyConfigured: 'sqlserver_ado' isn't an available database backend. Try using 'django.db.backends.XXX', where XXX is one of: 'mysql', 'oracle', 'postgresql', 'sqlite3'

My settings:

DATABASES = {
'default': {
    'NAME': 'TestDB',
    'ENGINE': 'sqlserver_ado',
    'HOST': 'STEPAN',
    'USER': '',
    'PASSWORD': '',
}

}

In this solution: Setting up django-mssql issues I found that my 'sqlserver_ado' should be in the same folder 'site-packages', which it is (Python IDLE shell):

>>> import sqlserver_ado
>>> sqlserver_ado
<module 'sqlserver_ado' from 'C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\Python36_64\\lib\\site-packages\\sqlserver_ado\\__init__.py'>
>>> import django
>>> django
<module 'django' from 'C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\Python36_64\\lib\\site-packages\\django\\__init__.py'>

I have a PyWin32 installed and importing in IDLE is fine (even the path is fine), yet still I get this error message.

Any ideas or advices?

Spec: Win10, Python 3.6, Visual Studio 2017, django-mssql 1.8, django 2.0.6, MsSQL (developer) and this DB is present (with flask I have no problem to connect to my local server [just for comparsion my connection string in another flask project:

SQLALCHEMY_DATABASE_URI = "mssql+pyodbc:///?odbc_connect={}".format(urllib.parse.quote_plus(
    "DRIVER={SQL Server};Server=STEPAN;Database=TestDB;Trusted_Connection=yes;"))

]), project was automaticly created by Visual Studio, command that throws this error:

python manage.py makemigrations
Stepan
  • 61
  • 1
  • 3
  • 12

1 Answers1

0

Responding to an old post, but - in case this will help others:

I found that, in some cases, you need to specify the SQL Server driver version too:

DATABASES = {
    'default': {
        'ENGINE': 'sql_server.pyodbc',
        'NAME': '<dbNAME_HERE',
        'HOST': '<SERVERNAME_HERE>\SQLEXPRESS',
        
        'OPTIONS': {
            'driver': 'ODBC Driver 17 for SQL Server',
        }        
    }
}

This is for a DJANGO project, but the issue may be similar...

jaytate
  • 163
  • 3
  • 7