Ardalan Shahgholi
Ardalan Shahgholi

Reputation: 12575

why python manage.py sql polls has error?

I use django .

I create in this file models.py my model like this :

from django.db import models

class Poll(models.Model):
    question = models.CharField(max_length=200)
    pub_date = models.DateTimeField('date published')

class Choice(models.Model):
    poll = models.ForeignKey(Poll)
    choice_text = models.CharField(max_length=200)
    votes = models.IntegerField(default=0)

And I change this file settings.py like this

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'polls',
)

And I change mu database on SQL Server 2012

DATABASES = {
    'default': {
        'NAME': 'DjangoFirst',
        'ENGINE': 'sqlserver_ado',
        'HOST': 'PCClient',
        'USER': 'sa',
        'PASSWORD': 'sa',
    }
}

When I execute this command in Command prompt

python manage.py sql polls

I get this error :

django.core.exceptions.ImproperlyConfigured: 'sqlserver_ado' isn't an available
database backend.
Try using 'django.db.backends.XXX', where XXX is one of:
    u'mysql', u'oracle', u'postgresql_psycopg2', u'sqlite3'
Error was: No module named sqlserver_ado.base

What is(are) wrong ?

Upvotes: 1

Views: 1539

Answers (3)

Ardalan Shahgholi
Ardalan Shahgholi

Reputation: 12575

Finally I found the answer.

I most use from an another version of Django that support SQL Server 2012 and load that in my Python.

I think django-mssql 1.4rc2 is a good for my purpose.

This is "Python: Package Index > django-mssql" of version of Django that support SQL Server 2005 and later.

However , I can not use Django 1.6 and connect to SQL Server 2012 yet.

Upvotes: 1

bruno desthuilliers
bruno desthuilliers

Reputation: 77912

The error message seems quite explicit: your default database settings are asking for a django database backend that cannot be found - either it does not exist or is not installed or you don't pass the correct python qualified name to your backend.

Upvotes: 1

greg
greg

Reputation: 1416

You should to select needed backend module (see all availible modules in comment line). Correct this line:

ENGINE = 'postgresql_psycopg2' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'

Upvotes: 1

Related Questions