无法使用pymssql连接到Microsoft Sql Server

时间:2013-06-08 10:21:56

标签: python sql sql-server

代码:

import pymssql
conn = pymssql.connect(host='BD', user='user', password='pass', database='Test')

它返回:

pymssql.InterfaceError: Connection to the database failed for an unknown reason

/etc/freetds/freetds.conf:

[BD]
        host = ip (not in local)
        port = 1219
        tds version = 7.0

我试试:

tsql -S BD -U user

它返回:

1Error 20009 (severity 9):
    Unable to connect: Adaptive Server is unavailable or does not exist
    OS error 111

如何解决?这是否意味着,我需要在Windows上打开PC上的端口?怎么做?

感谢。

0 个答案:

没有答案