I used Django to connect to SQL Server 2016 and I started executing
Python3" manage.py Runserver 8000
Terminal prompt:
django.db.utils .InterfaceError: ('28000', "[28000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Login failed for user 'test'. (18456) (SQLDriverConnect)")”

I don't know where the problem is.
This is my database configuration
DATABASES = {
'default': {
'ENGINE': 'sql_server.pyodbc',
'NAME':'testDB',#db name
'USER':'test',#db longin user
'PASSWORD':'test#2021',#db longin pwd
'HOST': '10.32.9.51',#db host
'PORT': '1433',#port,default1433
'OPTIONS': {#odbc driver
'provider': 'SQLOLEDB', # Have also tried 'SQLCLI11' and 'SQLOLEDB'
'driver': 'ODBC Driver 17 for SQL Server',
'MARS_Connection': True,
},
}
}
But I use pyodbc to connect to the database and query. At this time, the query is successful。
import pyodbc
try:
conn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};SERVER=10.32.9.51;PORT=1433;DATABASE= testDB;UID=test;PWD=test#2021')
cursor=conn.cursor()
cursor.execute("select getdate()")
row=cursor.fetchone()
while row:
print("sqlserver date:%s"%(row[0]))
row=cursor.fetchone()
print(row)
conn.close()
except Exception as e:
print("DB Error")
print("DB Error:"+str(e))

System environment:
System:Centos 7
python: 3.7.9、
Django:2.1.15、
django-mssql:1.8、
django-pyodbc:1.1.3、
django-pyodbc-azure:2.1.0.0、
django-sqlserver:1.11、
djangorestframework:3.12.2、
pip:21.0.1、
pymssql:2.1.5、
PyMySQL:1.0.2、
pyodbc:4.0.30、
SQL Server configuration:


