程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Error from Python linked SQL Server

編輯:Python

python link sql server Report errors

Error reason :pymssql._pymssql.OperationalError: (20002, b'DB-Lib error message 20002, severity 9:\nAdaptive Server connection failed

The code works well on both my colleagues' computers and my old computers , The result was a new computer , It's a mistake .

Tried similar error reporting , Said to bring the code , It turns out that with the code , The return is None( Colleagues can run normally without code , Taking the code is also a return None)
A friend said that the new computer may lack some configurations , We won't check the details .
Now I'm desperate , I really don't know what happened .
The code is as follows :
from email import charset
import pymssql

# Building links
coon = pymssql.connect("host", user name ", " password ", " Database name ")
if coon:
print(' Successful connection ')
# Create cursors
cursor = coon.cursor()
#sql command
sql = "SELECT TOP 1 * FROM cems_project WHERE object=' Use cases 1 automation ' ORDER BY lastUpdateTime DESC"
# Take the data
cursor.execute(sql)
data = cursor.fetchone()
print(data)
else:
print(' The connection fails ')


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved