问题描述
我知道 django-mssql-1.6 / README 指出:
SQL Server版本
支持的版本:
- 2008
- 2008r2
- 2012
但是,看到1.6版是最新版本,我想知道是否有人能够找到一种连接到MS SQL Server 2014的方法。我正在尝试,但收到错误消息:
django.db.utils。 OperationalError:(com_error(-2147352567,'Exception occurred。',(0,u'ADODB.Connection',u'Provider找不到,可能没有被正确的安装'',u'C:\Windows\HELP \ADO270.CHM',1240655,-2146824582),无),u'Error打开连接:DATA SOURCE = 127.0.0.1;初始目录= testdb;集成安全= SSPI; PROVIDER = sqlncli10; DataTypeCompatibility = 80; MARS连接= True')
使用配置:
DATABASES = {
pre>
'd efault':{
'ENGINE':'sqlserver_ado',
'NAME':'testdb'
}
}
解决方案据我所见,您使用的是正确版本的django-mssql和Django。我最近从1.6变为1.7,不得不更改DB后端,因为django 1.7不再支持
sql_server.pyodbc
。更改为django-mssql(sqlserver_ado
)时遇到这个问题。
问题是你使用错误的提供者。 Django-mssql使用SQLCLI10
作为默认提供者,这对我来说也没有用。只要您使用SQLOLEDB
提供程序,就可以在DB配置中添加选项哈希,就像上面的答案一样,解决你的问题。这是我的配置:DATABASES = {
'default':{
'NAME' CVH_Dev',
'ENGINE':'sqlserver_ado',
'HOST':'192。***。212.2 **',
'USER':'USER',
'PASSWORD':'PWD',
'OPTIONS':{
'provider':'SQLOLEDB',
'use_legacy_date_fields':'True'
}
}
}
使用
SQLOLEDB
提供者选项,它将工作。
希望这有帮助。i am aware that the django-mssql-1.6/README states:
SQL Server Versions
Supported Versions:
- 2008
- 2008r2
- 2012
but, seeing as v. 1.6 is the latest version available, i was wondering if anyone was able to find a way to connect to an MS SQL Server 2014. I am trying, but getting the error message:
django.db.utils.OperationalError: (com_error(-2147352567, 'Exception occurred.', (0, u'ADODB.Connection', u'Provider cannot be found. It may not be properly installed.', u'C:\Windows\HELP\ADO270.CHM', 1240655, -2146824582), None), u'Error opening connection: DATA SOURCE=127.0.0.1;Initial Catalog=testdb;Integrated Security=SSPI;PROVIDER=sqlncli10;DataTypeCompatibility=80;MARS Connection=True')
using config:
DATABASES = {
'default': {
'ENGINE': 'sqlserver_ado',
'NAME': 'testdb'
}
}
As far as I can see, you are using the correct versions of django-mssql and Django. I recently moved from 1.6 to 1.7 and had to change the DB backend since sql_server.pyodbc
is no longer supported by django 1.7. I came across this issue when changing to django-mssql (sqlserver_ado
). The problem is you are using the wrong provider. Django-mssql uses SQLCLI10
as the default provider, which also did not work for me. Adding an option hash to your DB config, like the one in the above answer, will solve your problem as long as you use the SQLOLEDB
provider. This is my config:
DATABASES = {
'default': {
'NAME': 'CVH_Dev',
'ENGINE': 'sqlserver_ado',
'HOST': '192.***.212.2**',
'USER': 'USER',
'PASSWORD': 'PWD',
'OPTIONS': {
'provider': 'SQLOLEDB',
'use_legacy_date_fields': 'True'
}
}
}
Use the SQLOLEDB
provider option and it will work.Hope this helps.
这篇关于使用django-mssql-1.6建立与MS SQL Server 2014的连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!