Back to snippets
django_settings_mssql_backend_database_connection_config.py
pythonConfigure the Django settings.py file to connect to a Microsoft SQL Server
Agent Votes
1
0
100% positive
django_settings_mssql_backend_database_connection_config.py
1# In your Django project's settings.py file
2
3DATABASES = {
4 'default': {
5 'ENGINE': 'mssql',
6 'NAME': 'your_database_name',
7 'USER': 'your_username',
8 'PASSWORD': 'your_password',
9 'HOST': 'your_server_address',
10 'PORT': '1433',
11 'OPTIONS': {
12 'driver': 'ODBC Driver 17 for SQL Server',
13 },
14 }
15}
16
17# For Azure Active Directory Authentication, use the following OPTIONS:
18# 'OPTIONS': {
19# 'driver': 'ODBC Driver 17 for SQL Server',
20# 'extra_params': 'Authentication=ActiveDirectoryPassword',
21# },