question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

Hi all,

I get the following error when doing runserver:

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'

My configuration in settings is like that:

{'NAME': '***',
  'USER': '***',
  'PASSWORD': '***',
  'HOST': '192.168.10.70',
  'PORT': '',
  'ENGINE': 'sql_server.pyodbc',
  'OPTIONS': {'driver': 'ODBC Driver 17 for SQL Server'}
}

The library seems to be installed, this import works without errors: import sql_server.pyodbc

Any help appreciated.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:6

github_iconTop GitHub Comments

13reactions
davidjbcommented, Mar 4, 2020

I had the same issue and symptoms on Django 3.0.3, packages installed via pipenv. In my case, I was using the original django-pyodbc-azure package and switched over to django-mssql-backend. For me, I had installed the new package and then uninstalled the old one, meaning that I had a conflict because both packages use the same namespace. In other words, sql_server.pyodbc could be imported fine but it was an empty module which caused Django to error here as sql_server.pyodbc.base couldn’t be imported. I solved my issue with:

pipenv uninstall django-mssql-backend
pipenv install django-mssql-backend
0reactions
lewisMachilikacommented, Apr 7, 2022

I had the same issue and symptoms on Django 3.0.3, packages installed via pipenv. In my case, I was using the original django-pyodbc-azure package and switched over to django-mssql-backend. For me, I had installed the new package and then uninstalled the old one, meaning that I had a conflict because both packages use the same namespace. In other words, sql_server.pyodbc could be imported fine but it was an empty module which caused Django to error here as sql_server.pyodbc.base couldn’t be imported. I solved my issue with:

pipenv uninstall django-mssql-backend
pipenv install django-mssql-backend

This one worked for me

Read more comments on GitHub >

github_iconTop Results From Across the Web

Django python 'sql_server.pyodbc' isn't an available database ...
I removed the django-pyodbc-azure and django-mssql-backend packages since they only support the older django versions.
Read more >
Error when trying to conect to MS SQL backend - Django Forum
ImproperlyConfigured'>, ImproperlyConfigured("'sql_server.pyodbc' isn't an available database backend or couldn't be imported.
Read more >
Django python 'sql_server.pyodbc' isn't an available database ...
ImproperlyConfigured: 'sql_server.pyodbc' isn't an available database backend. Try using 'django.db.backends.XXX', where XXX is one of: 'mysql', 'oracle', ...
Read more >
4.3. Databases and database drivers - CRATE - Read the Docs
For SQL Server: with Django use django-mssql-backend, and with SQLAlchemy use pyodbc, both via ODBC. For the ODBC drivers: under Windows, use native...
Read more >
Django SQL server connection not working in Pycharm
"%r isn't an available database backend or couldn't be " "imported. ... Obviously sql_server.pyodbc is not in django.db.backends.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found