Configure Django with MS SQL Server database

五迷三道 提交于 2019-12-14 02:13:14

问题


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?


回答1:


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': '',
    }
}


来源:https://stackoverflow.com/questions/20265854/configure-django-with-ms-sql-server-database

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!