3

I have got following in my django env

Django==1.8.1
django-mssql==1.6.2
django-pyodbc==0.2.8
pyodbc==3.0.10
pywin32==219 
sql-server.pyodbc==1.0

and the following in my settings.py

DATABASES = {
 'default': {
 'NAME': 'db_name',
 'ENGINE': 'sqlserver_ado',
 'HOST': 'host_name\\SQLEXPRESS',
 'USER': 'user_name',
 'PASSWORD': 'password',
 }
}

But when I try to migrate it I face the following error. Am I missing out something?

django.core.exceptions.ImproperlyConfigured: 'sqlserver_ado' isn't an available database backend.
Try using 'django.db.backends.XXX', where XXX is one of:
'base', 'mysql', 'oracle', 'postgresql_psycopg2', 'sqlite3'
Error was: cannot import name 'BaseDatabaseWrapper'
Jakuje
26.2k12 gold badges72 silver badges80 bronze badges
asked May 5, 2015 at 11:32
3
  • See this answer. Commented May 5, 2015 at 11:41
  • I am using sql server 2012 but there they mention as 2005/2008. Though I tried it. I get the same error. I have the complete sqlserver_ado folder in /site-packages/ Commented May 5, 2015 at 12:19
  • looks like you have an extra comma after password fwiw Commented Nov 8, 2016 at 19:35

7 Answers 7

1

I had been using django 1.8, and solved it by downgrading to django 1.6. These are the libraries installed in my virtualenv after the downgrade, and when I got it working.:

(env)$ pip list
argparse (1.2.1) 
Django (1.6) 
django-pyodbc (0.2.8) 
pip (1.5.4) 
pyodbc (3.0.10) 
setuptools (2.2) 
wsgiref (0.1.2) 
answered May 12, 2015 at 3:05
Sign up to request clarification or add additional context in comments.

Comments

1

You need to install the python package django-sqlserver.

answered May 5, 2015 at 12:34

2 Comments

I installed django-sqlserver, still it is not working.
then install django-mssql also.
1

Try using django-pyodbc instead.

In settings.py, replace the ENGINE setting with this:

'ENGINE': 'django_pyodbc',
Will
24.8k14 gold badges100 silver badges111 bronze badges
answered Dec 29, 2015 at 3:49

Comments

1

Try these settings with Django version 1.8.

DATABASES = {
'default': {
 'ENGINE': 'sqlserver_ado',
 'NAME': '',
 'USER': '',
 'PASSWORD': '',
 'HOST': '',
 'PORT': '1433',
 'OPTIONS': {
 'provider': 'SQLOLEDB', #SQLNCLI11 , SQLOLEDB
 'use_legacy_date_fields': 'True',
 #'extra_params' : 'DataTypeCompatibility=80;MARS Connection=True',
 #'connect_timeout': 0
 }
}

}

answered Apr 5, 2018 at 6:06

Comments

0

For Django Version 1.11 I am using this settings:

DATABASES = {
 'default': {
 'NAME': 'DbName',
 'ENGINE': 'sql_server.pyodbc',
 'HOST': 'localhost',
 'PORT': '1433',
 'USER': 'DBUser',
 'PASSWORD': 'Db password',
 'OPTIONS': {
 'driver': 'ODBC Driver 13 for SQL Server'
 }
 }
}
answered Jul 11, 2018 at 19:37

Comments

0

After Lost of Searching in django docs and i think most of the link in Google regarding Django with MSSQL Server below are my Configurations.

My python version is

Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)]

Required Packages are :

django==1.11.16

django-pyodbc-azure==2.1.0.0

pyodbc=4.0.24

pywin32==224

All Above packages are the latest one At the time of posting this post.

For Downloading pywin32 use this link (Latest version is 224)

https://github.com/mhammond/pywin32/releases

After that you need to download SQL SERVER driver, i am currently on windows 10 so i downloaded the latest one that 2017 SQL SERVER DRIVER.

https://www.microsoft.com/en-us/download/details.aspx?id=56567

After that in Django Settings.py file this is my Configuration

if you did not mention your driver version in option field this will not work so be attentive .

DATABASES = {
 'default': {
 'NAME': 'abc', #this is your database name
 'ENGINE': 'sql_server.pyodbc', #this is your Engine 
 'HOST': 'x.x.x.x', #MSSQL SERVER ip
 'USER': 'user', # username
 'PASSWORD': 'password', # password 
 'OPTIONS': { # mention your Driver Version
 'driver': 'ODBC Driver 17 for SQL Server' # Mine Driver version is 2017 so that i mentioned 17 , mention According to yourself 
 }
 }
}
answered Nov 29, 2018 at 5:38

Comments

0

If u add an option like :

'OPTIONS': {
 'driver': 'ODBC Driver 13 for SQL Server'
 }

U have to make sure u already install OCBC Driver 13 for SQL Server. (This would be inside Administrative Tools> Data Source OCBC and when u click Add button this driver should be in the list otherwise u have to install)

If still not working, try to install: pip install django-pyodbc-azure

answered Sep 20, 2019 at 4:37

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.