Skip to content

Getting started

Sicong edited this page Jul 29, 2021 · 9 revisions

Install Python

  • Make sure Python and pip are installed.

Installation for Windows

  1. Install Django:
pip install django
  1. Install mssql-django:
pip install mssql-django
  1. Set the ENGINE setting in the settings.py file used by your Django application or project to mssql module path :

    'ENGINE': 'mssql'

Installation for Linux

  1. Install Django
pip install django
  1. Install Microsoft ODBC Driver 17 for SQL Server (or equivalent)

  2. Install mssql-django :

pip install mssql-django
  1. Set the ENGINE setting in the settings.py file used by your Django application or project to 'mssql' module path :

    'ENGINE': 'mssql'

Example

Here is an example of the database settings:

DATABASES = {
    'default': {
        'ENGINE': 'mssql',
        'NAME': 'mydb',
        'USER': 'user@myserver',
        'PASSWORD': 'password',
        'HOST': 'myserver.database.windows.net',
        'PORT': '',

        'OPTIONS': {
            'driver': 'ODBC Driver 17 for SQL Server',
        },
    },
}

# set this to False if you want to turn off pyodbc's connection pooling
DATABASE_CONNECTION_POOLING = False