2

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?

1 Answer 1

2

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': '',
    }
}
Sign up to request clarification or add additional context in comments.

3 Comments

how i can use django-mssql 1.4rc2 for connect to sql server?
Here's a version which supports both SQL Server 2012 and Django 1.5. I have used it in the past and can assure that it is working fine, though you need pywin32 build 217 or newer
for the 2020 readers who ended up here like me and i would highly recommend looking at pypi.org/project/django-pyodbc-azure got this working with my webapp in 15 mins with a brand new s0 azure sql db.

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.