1. django-mssql和pywin32
- python版本:python2.7 or 3.6
- sql server版本:2012,2014,2016
- django版本:django可能只支持到1.X
- 模块:django-mssql, version 1.6.x
- 最后更新时间:2018年6月
- 配置方法
DATABASES = {
'default': {
'ENGINE': 'sqlserver',
'HOST': 'mysqlserverhost\\instance', # Replace with host name where you have MSSQL server running
'NAME': 'mydbname', # Replace with name of the database on the MSSQL server
'USER': 'username', # Replace with user name
'PASSWORD': '*****', # Replace with password
},
}
2. django-pyodbc
- python版本:python3可能部分不支持,待测
- sql server版本:2000, 2005, 2008, 2012
- django版本:支持Django 1.4-1.10,最后支持Django 2.0,需安装pip install django-pyodbc>=2.0.0a1
- 模块:django-pyodbc
- 最后更新时间:2018年4月
- 配置方法
DATABASES = {
'default': {
'ENGINE': "django_pyodbc",
'HOST': "127.0.0.1,1433",
'USER': "mssql_user",
'PASSWORD': "mssql_password",
'NAME': "database_name",
'OPTIONS': {
'host_is_server': True
},
}
}
3. django-pyodbc-azure
- python版本:3.0 or newer
- sql server版本:2008/2008R2, 2012, 2014, 2016, 2017 and Azure SQL Database
- django版本:2.1
- 模块:pyodbc, django-pyodbc-azure
- 最后更新时间:2018年10月
- 配置方法
DATABASES = {
'default': {
'ENGINE': 'sql_server.pyodbc',
'NAME': 'mydb',
'USER': 'user@myserver',
'PASSWORD': 'password',
'HOST': 'myserver.database.windows.net',
'PORT': '',
'OPTIONS': {
'driver': 'ODBC Driver 13 for SQL Server',
},
},
}
我的
'OPTIONS': {
'driver': 'SQL Native Client',
'MARS_Connection': True,
"init_command": "SET foreign_key_checks = 0;",
},
推荐使用django-pyodbc-azure,其中azure-1.11支持Django 1.11.X,SQL Server 2005, 2008/2008R2, 2012, 2014, 2016, 2017 and Azure SQL Database