Ardalan Shahgholi
Ardalan Shahgholi

Reputation: 12575

Configure Django with MS SQL Server database

I'm setting up a Django application and I want to use SQL Server 2012 for my database.

To configure my website I'm following this section of the official Django documentation.

In the section Database setup I found instructions for changing RDBMS.

And in settings.py file I found these instructions for setting up Django with SQlite.

DATABASES = {
'default': {
    'ENGINE': 'django.db.backends.sqlite3',
    'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}

How I can change this configuration to use SQL Server 2012 instead?

Upvotes: 2

Views: 7431

Answers (1)

jpwagner
jpwagner

Reputation: 553

Looks like you'll need django-mssql which requires django 1.4 or below:

http://django-mssql.readthedocs.org/en/latest/

It has a pip package: https://pypi.python.org/pypi/django-mssql

Then include in your settings.py:

DATABASES = {
    'default': {
        'NAME': 'my_database',
        'ENGINE': 'sqlserver_ado',
        'HOST': 'dbserver\\ss2008',
        'USER': '',
        'PASSWORD': '',
    }
}

Upvotes: 2

Related Questions