結弦 2020-07-22 17:16 采纳率: 50%
浏览 2044
已采纳

python的pymssql无法连接至本地数据库

能试的方法都试过了,还请大佬帮忙看一下

Traceback (most recent call last):
  File "src\pymssql.pyx", line 636, in pymssql.connect
  File "src\_mssql.pyx", line 1957, in _mssql.connect
  File "src\_mssql.pyx", line 676, in _mssql.MSSQLConnection.__init__
  File "src\_mssql.pyx", line 1683, in _mssql.maybe_raise_MSSQLDatabaseException
_mssql.MSSQLDatabaseException: (18456, b"\xe7\x94\xa8\xe6\x88\xb7 'sa' \xe7\x99\xbb\xe5\xbd\x95\xe5\xa4\xb1\xe8\xb4\xa5\xe3\x80\x82DB-Lib error message 20018, severity 14:\nGeneral SQL Server error: Check messages from the SQL Server\nDB-Lib error message 20002, severity 9:\nAdaptive Server connection failed (DESKTOP-AT6GGIA:1433)\n")

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\桌面文件夹\成信大\Python\灰度模型\与数据库的链接.py", line 2, in <module>
    conn = pymssql.connect(server = 'DESKTOP-AT6GGIA' , user = 'sa' , password = 'llm1218' , database = 'elevator')
  File "src\pymssql.pyx", line 642, in pymssql.connect
pymssql.OperationalError: (18456, b"\xe7\x94\xa8\xe6\x88\xb7 'sa' \xe7\x99\xbb\xe5\xbd\x95\xe5\xa4\xb1\xe8\xb4\xa5\xe3\x80\x82DB-Lib error message 20018, severity 14:\nGeneral SQL Server error: Check messages from the SQL Server\nDB-Lib error message 20002, severity 9:\nAdaptive Server connection failed (DESKTOP-AT6GGIA:1433)\n")
  • 写回答

5条回答 默认 最新

  • lihaopeng1024 2020-09-15 22:15
    关注

    数据库连接字符串 添加charset='CP936' 就OK了

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

问题事件

  • 已采纳回答 9月19日

悬赏问题

  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改
  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥15 键盘指令混乱情况下的启动盘系统重装
  • ¥40 复杂的限制性的商函数处理