By default Django support only Postgres and SQLite. But you can connect SQL database. You need to install a package for SQL database connectivity.

Using mssql-django 1.0 package you can connect SQL database.

Installation

  1. Install  Django

  2. Install mssql-django:

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

    'ENGINE': 'mssql'

Standard Django Settings :


The following entries in database-level settings control the behavior of the backend.
  • ENGINE

    String. It must be "mssql".

  • NAME

    String. Database name. Required.

  • HOST

    String. SQL Server instance in "server\instance" format.

  • PORT

    String. Server instance port. An empty string means the default port.

  • USER

    String. Database user name.

  • PASSWORD

    String. Database user password.


OPTIONS
  • driver

    String. ODBC Driver to use ("ODBC Driver 17 for SQL Server""SQL Server Native Client 11.0""FreeTDS" etc). Default is "ODBC Driver 17 for SQL Server".

Configuration Example :

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