I want to connect mssql server in django rather than default database please suggest me code

I want to connect mssql server in django rather than default database please suggest me the code which, I've to write in "settings.py" file

only " settings.py" file code what i've to write in the file

You actually can install package for mssql:

pip install mssql-django

Then change your settings.py:

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

And btw you can turn off pyodbc's connection pooling by adding this in your settings:

DATABASE_CONNECTION_POOLING = False
Back to Top