I'm trying to connect to Azure SQL server using Python's pymssql. The problem is that the following script works but only sometimes, the other times I get this error:
_mssql.MSSQLDatabaseException: (20002, b'DB-Lib error message 20002, severity 9:
Adaptive Server connection failed
')
This is the script I'm using:
import pymssql
conn = pymssql.connect(server='x', user='x', password='x', database='x')
cursor = conn.cursor()
cursor.execute('SELECT * FROM customers');
row = cursor.fetchone()
while row:
print (str(row[0]) + " " + str(row[1]) + " " + str(row[2]))
row = cursor.fetchone()
It would help me greatly if someone can tell me why this above script works only sometimes and rest of the times I get the "Adaptive Server connection failed" error.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…