将Django与MSSQL服务器连接 [英] Connecting Django with MSSQL server

查看:68
本文介绍了将Django与MSSQL服务器连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将Django应用程序连接到SQL Server2016.我尝试使用django-pyodbc,但它不支持Django 1.11.相反,我安装了django-mssql 1.8.当我尝试运行该应用程序时,出现此错误.

I'm trying to connect my Django app to SQL Server 2016. I've tried using django-pyodbc but it doesn't support Django 1.11. Instead I installed django-mssql 1.8. When I try to run the application I get this error.

TypeError was unhandled by user code
Message: 'NoneType' object is not callable

在manage.py中的 execute_from_command_line(sys.argv)

At execute_from_command_line(sys.argv) in manage.py

这是来自settings.py的我的数据库

Here is my DATABASES from settings.py

DATABASES = {
'default': {
    'ENGINE': 'sqlserver_ado',
    'NAME': 'TEST2',
    'HOST': 'PCNAME\SQLEXPRESS',
    'USER': '',
    'PASSWORD': '',
    'OPTIONS' : {
     'provider': 'SQLOLEDB',
     'use_mars': True,
     },
}
}

我已经尝试了默认提供程序和SQLOLEDB提供程序,但是总是遇到相同的错误.我也尝试过设置和不设置用户名和密码,但是错误仍然相同.我可以连接到本地MySQL数据库.

I've tried both the default and SQLOLEDB provider but always get the same error. I've also tried with and without user and password set but the error remains the same. I am able to connect to a local MySQL DB just fine.

我正在运行Windows 10,Visual Studio 2015,SQL Server Express 2016

I'm running Windows 10, Visual Studio 2015, SQL Server Express 2016

这是 pip冻结

appdirs==1.4.3
Django==1.11
django-mssql==1.8
mysqlclient==1.3.10
packaging==16.8
pyodbc==4.0.16
pyparsing==2.2.0
pytz==2017.2
six==1.10.0

这是我的要求.txt

django==1.11
mysqlclient==1.3.10
django-mssql==1.8

推荐答案

django-mssql文档,最新版本仅支持Django 1.8,因此不适用于Django 1.11.

As stated in the django-mssql documentation, the latest release only supports Django 1.8, so it won't work with Django 1.11.

您将不得不等待,直到软件包支持较新版本的django才能进行升级.这是将Django与不支持的数据库后端一起使用时的问题,您需要依赖第三方软件包的维护,而这似乎很难与Django保持最新.

You will have to wait until the package supports newer versions of django to upgrade. That is the problem when using Django with non-supported database backends, you depend on the third party packages maintenance, and this one seems to have trouble staying up to date with Django.

这篇关于将Django与MSSQL服务器连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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