Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django python 'sql_server.pyodbc' isn't an available database backend

I'm trying to connect my Django app to microsoft sql database on apache server but I get the following error messages:

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

I have installed django-pyodbc-azure and it's showing up as part of (pip freeze list):

Django==2.1
django-pyodbc==1.1.3
django-pyodbc-azure==2.1.0.0
pyodbc==4.0.25

Here is settings.py database configuration:

'default': {
    'ENGINE': 'sql_server.pyodbc',
    'NAME': 'name',
    'USER': 'user',
    'PASSWORD': 'password',
    'HOST': 'host',
    'PORT': '',

    'OPTIONS': {
        'driver': 'ODBC Driver 17 for SQL Server',
    },

},

Inside site-packages folder, it's doesn't show the actual django-pyodbc-azure folder but when i run the command (pip show django-pyodbc-azure), it shows the package location (/usr/local/lib/python3.5/dist-packages) which means it's successfully installed.

So I'm not really sure what is the problem.

like image 537
Mack Avatar asked Oct 16 '22 06:10

Mack


1 Answers

I had the same problem. Somehow the installation of the azure-backend messed up my project.

I removed the django-pyodbc-azure and django-mssql-backend packages since they only support the older django versions. Afterwards i installed the mssql backend from https://github.com/microsoft/mssql-django

pip uninstall django-pyodbc-azure
pip uninstall django-mssql-backend
pip install mssql-django

Then i configured the DB to use 'ENGINE': 'mssql'

After this i was able to connect to our MSSQL DB using Django 3.2!

like image 182
eckad158 Avatar answered Oct 20 '22 06:10

eckad158