使用pymssql出现unknown reason错误,请大佬们进来看一下

hno3000 2017-04-19 05:50:36
在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.


求各位大佬帮忙看一下,是什么问题,怎么解决,感激不尽。
...全文
689 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
ckc 2017-04-22
  • 打赏
  • 举报
回复
你就换用odbc连接ms sql试下吧

37,719

社区成员

发帖
与我相关
我的任务
社区描述
JavaScript,VBScript,AngleScript,ActionScript,Shell,Perl,Ruby,Lua,Tcl,Scala,MaxScript 等脚本语言交流。
社区管理员
  • 脚本语言(Perl/Python)社区
  • IT.BOB
加入社区
  • 近7日
  • 近30日
  • 至今

试试用AI创作助手写篇文章吧