Python 无法使用pymssql连接到Microsoft Sql Server
代码: 它返回:Python 无法使用pymssql连接到Microsoft Sql Server,python,sql,sql-server,Python,Sql,Sql Server,代码: 它返回: import pymssql conn = pymssql.connect(host='BD', user='user', password='pass', database='Test') tsql -S BD -U user /etc/freetds/freetds.conf: pymssql.InterfaceError: Connection to the database failed for an unknown reason 我尝试: [BD]
import pymssql
conn = pymssql.connect(host='BD', user='user', password='pass', database='Test')
tsql -S BD -U user
/etc/freetds/freetds.conf:
pymssql.InterfaceError: Connection to the database failed for an unknown reason
我尝试:
[BD]
host = ip (not in local)
port = 1219
tds version = 7.0
它返回:
import pymssql
conn = pymssql.connect(host='BD', user='user', password='pass', database='Test')
tsql -S BD -U user
如何修复它?这是否意味着,我需要在装有Windows的pc上打开端口?怎么做
谢谢。端口1219不是SQL Server的默认端口,您确定它正确吗?有关您的操作系统和SQL Server版本的更多信息可能会有用,但您可以检查基本连接:SQL Server是否实际启用了TCP/IP,您是否可以使用本机客户端工具从Windows PC进行连接,例如sqlcmd.exe?数据库服务器的主机:Windows 7、microsoft SQL Server 2000