I am trying to connect to an Azure SQL server using Python pymssql. The problem is that the following script works, but only sometimes, in other cases, I get this error:
_mssql.MSSQLDatabaseException: (20002, b'DB-Lib error message 20002, severity 9: \ n Adaptive connection to the server failed \ n ')
This is the script I use:
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 a lot if someone tells me why this script above only works sometimes and at the same time when I get the error message “Could not connect to Adaptive Server”.
source share