Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using sql server on django

Tags:

python

django

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'
like image 624
Kiran Kumar Avatar asked Feb 15 '26 18:02

Kiran Kumar


2 Answers

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)                                          
like image 87
isaaclw Avatar answered Feb 17 '26 06:02

isaaclw


You need to install the python package django-sqlserver.

like image 23
HiroshiFuu Avatar answered Feb 17 '26 08:02

HiroshiFuu