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 ')