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
Install Django
Install mssql-django:
pip install mssql-django
Set the
ENGINE
setting in thesettings.py
file used by your Django application or project to'mssql'
:'ENGINE': 'mssql'
Standard Django Settings :
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.
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', }, }, }