0

I want to use SQL Server as the backend for Django.

I install pyodbc, django-pyodbc, django-pyodbc-azure

In settings.py I replace a Database

DATABASES = {
    'default': {
            'ENGINE': 'sql_server.pyodbc',
            'NAME': 'xxx',
            'USER': 'xxx',
            'PASSWORD': 'xxx',
            'HOST': 'xxx.database.windows.net',
            'PORT': '1433',
            'OPTIONS': {
                'driver': 'SQL Server Native Client 11.0',
                'MARS_Connection': 'True',
            }
        }
}

if I run python manage.py syncdb Error:

django.core.exceptions.ImproperlyConfigured: 'sql_server.pyodbc' isn't an available database backend. Available options are: 'dummy', 'mysql', 'oracle', 'postgresql', 'postgresql_psycopg2', 'sql_server', 'sqlite3'
Error was: No module named sql_server.pyodbc.base

I use Visual Studio + Python 2.7

NoWar
  • 36,338
  • 80
  • 323
  • 498

1 Answers1

3

You may want to follow that documentation https://azure.microsoft.com/en-us/documentation/articles/web-sites-python-ptvs-django-sql/. The Python tools for Visual Studio makes things easier; still, even if you don't use them, the documentation will show you how they do, how they install pyodbc locally, then push it to the server while publishing.

Note that while Azure has 64 bit VMs, the Python environment must be 32 bits.

benjguin
  • 1,496
  • 1
  • 12
  • 21
  • That's what i'm doing. In visual studio in step python -> django sync db -> error: Unknown command: 'syncdb' Type 'manage.py help' for usage. The Python REPL process has exited – Michael Podgortsev Dec 31 '15 at 10:41
  • are you in 32 bits as described in the documentation? – benjguin Dec 31 '15 at 11:38
  • No, I think that is is my problem. Thank you. You know how I can install pip pyodbc for 64 bit? – Michael Podgortsev Dec 31 '15 at 11:54
  • the python tools for Visual Studio allow you to install with pip and easy_install in any virtual env. This is the easiest way to pip install. – benjguin Dec 31 '15 at 12:17
  • I will edit the answer with the importance of 32 bits. If you think this answers your question, and once your issue is solved, can you please check this as an answer? – benjguin Dec 31 '15 at 12:18
  • Please note, you shouldn't install pyodbc, django-pyodbc AND django-pyodbc-azure. All you need are pyodbc and django-pyodbc-azure. – FlipperPA Dec 31 '15 at 14:40
  • This answer is really amazing, my problem was also the fact my Visual Studio Python 3.6 environment was in 64 bit. As soon as I changed to a new 32 bit environment my problem was solved. – Scornwell Aug 09 '17 at 17:50