使用MS SQL Server数据库配置Django [英] Configure Django with MS SQL Server database

查看:233
本文介绍了使用MS SQL Server数据库配置Django的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在设置一个 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆