使用pymssql出现unknown reason错误,请大佬们进来看一下
在win10系统,使用elicpse+python使用pymssql连接mssql的时候,出现下面的错误,试过不少方法都解决不了,求各位大佬帮忙看一下:
File "pymssql.pyx", line 644, in pymssql.connect (pymssql.c:10892)
pymssql.InterfaceError: Connection to the database failed for an unknown reason.
代码很简单,如下:
import os
import pymssql
server="YLMF-1704061723\SQLEXPRESS:49672"
user="sa"
password="123"
database="test1"
charset="UTF-8"
print("wait")
conn=pymssql.connect(server,user,password,database,charset)
cursor=conn.cursor()
if not cursor:
raise Exception('fail1')
cursor.execute("""select getdate()""")
row=cursor.fetchone()
while row:
print("sqlserver version:%s"%(row[0]))
row=cursor.fetchone()
conn.close()
——————————报错信息:——————————————————————————————
Traceback (most recent call last):
File "pymssql.pyx", line 635, in pymssql.connect (pymssql.c:10734)
File "_mssql.pyx", line 1902, in _mssql.connect (_mssql.c:21821)
File "_mssql.pyx", line 638, in _mssql.MSSQLConnection.__init__ (_mssql.c:6594)
_mssql.MSSQLDriverException: Connection to the database failed for an unknown reason.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "E:\EclPro\test\src\sqltest.py", line 12, in <module>
conn=pymssql.connect(server,user,password,database,charset)
File "pymssql.pyx", line 644, in pymssql.connect (pymssql.c:10892)
pymssql.InterfaceError: Connection to the database failed for an unknown reason.
求各位大佬帮忙看一下,是什么问题,怎么解决,感激不尽。