使用MS SQL Server数据库配置Django [英] Configure Django with MS SQL Server database
问题描述
我正在设置一个 Django
应用程序,我想为我的数据库使用 SQL Server 2012
/ p>
要配置我的网站我正在关注这个部分的官方Django文档。
在数据库设置
部分中,我找到了更改 RDBMS
。
而在 settings.py
文件中,我发现使用<$ c $设置Django的这些说明c> SQlite 。
DATABASES = {
'default':{
'ENGINE':'django.db.backends.sqlite3',
'NAME':os.path.join(BASE_DIR,'db.sqlite3'),
}
}
如何更改此配置以使用 SQL Server 2012
看起来你需要需要django 1.4或更低版本的django-mssql:
http://django-mssql.readthedocs.org/en / latest /
它有一个pip包: https://pypi.python.org/pypi/django-mssql
然后加入您的settings.py:
DATABASES = {
'default':{
'NAME ':'my_database',
'ENGINE':'sqlserver_ado',
'HOST':'dbserver\\ss2008',
'USER':'',
'PASSWORD':'',
}
}
I'm setting up a Django
application and I want to use SQL Server 2012
for my database.
To configure my website I'm following this section of the official Django documentation.
In the section Database setup
I found instructions for changing RDBMS
.
And in settings.py
file I found these instructions for setting up Django with SQlite
.
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
How I can change this configuration to use SQL Server 2012
instead?
Looks like you'll need django-mssql which requires django 1.4 or below:
http://django-mssql.readthedocs.org/en/latest/
It has a pip package: https://pypi.python.org/pypi/django-mssql
Then include in your settings.py:
DATABASES = {
'default': {
'NAME': 'my_database',
'ENGINE': 'sqlserver_ado',
'HOST': 'dbserver\\ss2008',
'USER': '',
'PASSWORD': '',
}
}
这篇关于使用MS SQL Server数据库配置Django的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!