1

I need connect my Django website to Azure SQL database.I use visual studio. And Python 2.7 for 64 bit.

I use this https://azure.microsoft.com/en-us/documentation/articles/web-sites-python-ptvs-django-sql/ for create database config

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',
            }
        }
}

I installed pips: pyodbc and django-pyodbc-azure - I think that them for 32 bit.

If I run python manage.py syncdb from console - > error:

django.core.exceptions.improperlyconfigured 'sql_server.pyodbc' isn't an available databace backend.
No module named sql_server.pyodbc.base

If I run python-> Django Sync db from visual studio -> error:

Unknown command: 'syncdb'
Type 'manage.py help' for usage.
The Python REPL process has exited
  1. I don't understand if I can use pyodbc and django-pyodbc-azure for Python 64 bit and it is right for Azure?
  2. May be it is another problem?

3 Answers 3

1

I installed the latest python 2.7 64 bits version from https://www.python.org/ftp/python/2.7.11/python-2.7.11.amd64.msi, and leveraged it to create a virtual env in Visual Studio, install modules from requirements.txt, configured database info the same as you. enter image description here

Then clicked sync db, but I did occur your issue, it worked fine on my side.

You can try to leverage virtual env as the step 3 and step 4 mention on the post https://azure.microsoft.com/en-us/documentation/articles/web-sites-python-ptvs-django-sql/#create-the-project.

And here are the python modules with version in used: Django==1.8.4 pyodbc==3.0.10 django-pyodbc-azure==1.8.3.0

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you. I created new project and it is work right.
0

Make sure sql_server is under Python_xx\Lib\site-packages\ or in the environment PATH or PYTHONPATH

Comments

0
  1. Yes, you can, but if your Python is x86_64 version, then your packages pyodbc and django-pyodbc-azure need to be build for this 64 bits version, check this first if you install the packages from VS or directly from shell/powershell. Check your $PYTHONPATH

  2. I assume that you are using Django 1.9, syncdb was deprecated from Django 1.7 and don't work with Django 1.9, change your syncdb commands with ./manage.py makemigrations and ./manage.py migrate check:

    https://docs.djangoproject.com/en/1.9/intro/tutorial02/
    https://docs.djangoproject.com/en/1.9/topics/migrations/

Comments

Your Answer

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.