sql-serverdjangoazuredjango-pyodbcdjango-pyodbc-azure

Django+sql server - No module named sql_server.pyodbc.base


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


Solution

  • 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.