gpt4 book ai didi

django - 如何使用 django-mssql 连接到 SQL Server 2008 R2?

转载 作者:行者123 更新时间:2023-12-02 02:10:31 26 4
gpt4 key购买 nike

我不明白为什么我不能让 django 连接到 sql server 2008 r2。我在我们的服务器和 sql server 上拥有管理权限。我用 Windows Server 2008 sp2 构建了一个虚拟 Windows 框,因为我认为我可能对 django-mssql 有一些运气。我已经在 Windows 框中尝试了 django-pyodbc 和 django-mssql 但尚未成功。这是我的数据库设置:

DATABASES = {
'default': {
'ENGINE': 'sqlserver_ado', # Have also tried sql_server.pyodbc
'NAME': 'TMSEPLAY',
'USER': '***', # Omitted for post
'PASSWORD': '*******', # Omitted for post
'HOST': '172.16.1.14',
'PORT': '1434',
'OPTIONS': {
'provider': 'SQLCLI10', # Have also tried 'SQLCLI11' and 'SQLOLEDB'
'extra_params': 'DataTypeCompatibility=80'
}
}
}

我得到的错误:

C:\Python27\CourseData\mysite>manage.py syncdb
Traceback (most recent call last):
File "C:\Python27\CourseData\mysite\manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line
443, in execute_from_command_line
utility.execute()
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line
382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Python27\lib\site-packages\django\core\management\base.py", line 196,
in run_from_argv
self.execute(*args, **options.__dict__)
File "C:\Python27\lib\site-packages\django\core\management\base.py", line 232,
in execute
output = self.handle(*args, **options)
File "C:\Python27\lib\site-packages\django\core\management\base.py", line 371,
in handle
return self.handle_noargs(**options)
File "C:\Python27\lib\site-packages\django\core\management\commands\syncdb.py"
, line 57, in handle_noargs
cursor = connection.cursor()
File "C:\Python27\lib\site-packages\django\db\backends\__init__.py", line 306,
in cursor
cursor = self.make_debug_cursor(self._cursor())
File "C:\Python27\lib\site-packages\sqlserver_ado\base.py", line 193, in _curs
or
self.__connect()
File "C:\Python27\lib\site-packages\sqlserver_ado\base.py", line 168, in __con
nect
use_transactions=self.use_transactions,
File "C:\Python27\lib\site-packages\sqlserver_ado\dbapi.py", line 151, in conn
ect
raise OperationalError(e, "Error opening connection: " + connection_string)
sqlserver_ado.dbapi.OperationalError: (com_error(-2147352567, 'Exception occurre
d.', (0, u'ADODB.Connection', u'Provider cannot be found. It may not be properly
installed.', u'C:\\Windows\\HELP\\ADO270.CHM', 1240655, -2146824582), None), 'E
rror opening connection: DATA SOURCE=172.16.1.14,1434;Network Library=DBMSSOCN;I
nitial Catalog=TMSEPLAY;UID=***;PWD=********;PROVIDER=SQLCLI10;MARS Connection=Tr
ue;DataTypeCompatibility=80;MARS Connection=True')

如果有任何见解,我将不胜感激。谢谢。

最佳答案

我可以在该日志中看到一条错误消息:

$错误打开连接:DATA SOURCE=172.16.1.14 port:1434

所以我会查看是否所有实例都在运行并且可以通过端口 1434 在该机器上访问。

此外,以下内容可能会有所帮助: Setting up django-mssql issues

关于django - 如何使用 django-mssql 连接到 SQL Server 2008 R2?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13210013/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com