我想使用 SQL Server 作为 Django 的后端,但是在调试 Web 项目时得到了这个。 “sql_server.pyodbc”不是可用的数据库后端。错误是:没有名为 sql_server.pyodbc.base 的模块。
Python 环境 (Python 2.7) 与 Django (1.7)、pyodbc(3.0.10)、pywin32(218.3)。这是我的settings.py:
DATABASES = {
'default': {
'ENGINE': 'sql_server.pyodbc',
'NAME': 'DatabaseName',
'USER': 'user',
'PASSWORD': 'pwd',
'HOST': '127.0.0.1',
'PORT': '',
'OPTIONS': {
'driver': 'SQL Server Native Client 11.0',
'server': 'ServerName',
'MARS_Connection': True,
'dsn': 'MSSQL-PYTHON',
},
}
}
您尚未安装具有所需数据库后端的软件包。
Do:
pip install django-pyodbc
pip install django-pyodbc-azure
看到这个doc https://github.com/lionheart/django-pyodbc/#installation and this one https://pypi.python.org/pypi/django-pyodbc-azure/1.8.3.0.
第二个链接中的数据库设置示例:
DATABASES = {
'default': {
'ENGINE': 'sql_server.pyodbc',
'NAME': 'mydb',
'USER': 'user@myserver',
'PASSWORD': 'password',
'HOST': 'myserver.database.windows.net',
'PORT': '',
'OPTIONS': {
'driver': 'SQL Server Native Client 11.0',
},
},
}
#set this to `False` if you want to turn off pyodbc's connection pooling:
DATABASE_CONNECTION_POOLING = False
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)