如何使用Django-MSSQL连接到SQL Server 2008 R2



我无法弄清为什么我不能让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:Python27CourseDatamysite>manage.py syncdb
Traceback (most recent call last):
  File "C:Python27CourseDatamysitemanage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "C:Python27libsite-packagesdjangocoremanagement__init__.py", line
443, in execute_from_command_line
    utility.execute()
  File "C:Python27libsite-packagesdjangocoremanagement__init__.py", line
382, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:Python27libsite-packagesdjangocoremanagementbase.py", line 196,
 in run_from_argv
    self.execute(*args, **options.__dict__)
  File "C:Python27libsite-packagesdjangocoremanagementbase.py", line 232,
 in execute
    output = self.handle(*args, **options)
  File "C:Python27libsite-packagesdjangocoremanagementbase.py", line 371,
 in handle
    return self.handle_noargs(**options)
  File "C:Python27libsite-packagesdjangocoremanagementcommandssyncdb.py"
, line 57, in handle_noargs
    cursor = connection.cursor()
  File "C:Python27libsite-packagesdjangodbbackends__init__.py", line 306,
 in cursor
    cursor = self.make_debug_cursor(self._cursor())
  File "C:Python27libsite-packagessqlserver_adobase.py", line 193, in _curs
or
    self.__connect()
  File "C:Python27libsite-packagessqlserver_adobase.py", line 168, in __con
nect
    use_transactions=self.use_transactions,
  File "C:Python27libsite-packagessqlserver_adodbapi.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')

我感谢任何见解。谢谢。

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

$打开连接错误:数据源= 172.16.1.14端口:1434

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

另外,以下情况可能会有所帮助:设置DJANGO-MSSQL问题

相关内容

  • 没有找到相关文章

最新更新