1👍
To install specifically:
pip install Django==2.1.15
pip install django-pyodbc-azure-2019==2.1.0.1
DATABASES = {
'default': {
'ENGINE': 'sql_server.pyodbc',
'NAME': 'dtabase_name',
'USER': 'sa',
'PASSWORD': '123456',
'HOST': 'Your_host',
'PORT': '',
'OPTIONS': {
'driver': 'ODBC Driver 17 for SQL Server',
},
},
}
6👍
Resolved. Thanks to another forum
Installed 2019 version: Django backend for Microsoft SQL Server and Azure SQL Database using pyodbc, compatible with SQL Server 2019
pip install django-pyodbc-azure-2019
System check identified no issues (0 silenced).
September 19, 2020 – 18:52:09
Django version 2.1.15, using settings ‘mdm.settings’
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
I’ll create a new venv and share the procedure since the current one is a mess right now:
(venvAzure) luca@webserver:~/app/MDM_SQLServer$ pip freeze
certifi==2020.6.20
cffi==1.14.2
chardet==3.0.4
cryptography==3.1
Django==2.1.15
django-azure-sql-backend==2.1.1.1
django-mssql-backend==2.8.1
django-pyodbc==1.1.3
django-pyodbc-azure-2019==2.1.0.0
idna==2.10
msal==1.5.0
pycparser==2.20
PyJWT==1.7.1
pyodbc==4.0.30
pytz==2020.1
requests==2.24.0
six==1.15.0
urllib3==1.25.10
Thanks
1👍
I just create an account to answer thi question. I lost a lot of time until can fix that.
To work with SQL Server 2019 i nedded to update the Django to actual version, 3.x and installed django-mssql-backend, django-pyodbc, pyodbc
In youd DATABASE definitions, add this line to work:
‘OPTIONS’: {
‘driver’: ‘ODBC Driver 17 for SQL Server’,
},
- [Django]-Django request GET parameter value list
- [Django]-Django – Save modelForm even if no field are changed on POST
- [Django]-How make conditional expression on Django with default value of object?
- [Django]-Django handle Annonymous users
0👍
By adding the code below to "settings.py", you can check which ODBC Driver Version to use. *In my case, it’s "ODBC Driver 17 for SQL Server":
# "settings.py"
import pyodbc
print("This is " + pyodbc.drivers()[-1]) # ODBC Driver 17 for SQL Server
So for example, I use mssql-django to connect Django to MSSQL(SQL Server) with SQL Server Authentication. *I use SQL Server 2019 Express.
So, set the code below with "ODBC Driver 17 for SQL Server" in "OPTIONS" to "settings.py":
# "settings.py"
DATABASES = {
'default':{
'ENGINE':'mssql',
'NAME':'test',
'USER':'john',
'PASSWORD':'johnpw',
'HOST':'DESKTOP-QVRCPTA\SQLEXPRESS',
'PORT':'',
'OPTIONS': { # Here
'driver': 'ODBC Driver 17 for SQL Server',
},
}
}
- [Django]-Form loses ability to send POST requests after 2 ajax updates
- [Django]-Limiting results returned fromquery in django, python
- [Django]-How can I test to see if a class contains a particular attribute?