2013,'在查询期间与 MySQL 服务器失去连接 - Pymysql Microsoft sql 服务器管理工​​作室

2013, 'Lost connection to MySQL server during query - Pymysql Microsoft sql server management Studio

导入 pymysql

进口pymysql.cursors

def database_connect():

connection = pymysql.connect(host='XXXXXXX',
                             user='XXXXXXXX',
                             password='XXXXXXXXXXXXXXX',
                             db='XXXXXXXX',
                             port=default,
                             charset='utf8mb4',
                             connect_timeout=600,
                             cursorclass=pymysql.cursors.DictCursor)

cursor = connection.cursor()
cursor.execute("SELECT VERSION()")
data = cursor.fetchone()
print ("Database version : %s " % data)
connection.close()

错误:“013,'在查询期间与 MySQL 服务器失去连接”。 任何解决方案,请。

导入 pymssql

def database_connect():

  connection = pymssql.connect(host='XXXXXXX',
                         user='XXXXXXXX',
                         password='XXXXXXXXXXXXXXX',
                         database='XXXXXXXX',
                         port=default,
                         connect_timeout=600)

光标 = connection.cursor()

cursor.execute("SELECT VERSION()")

数据=cursor.fetchone()

打印("Database version : %s "%数据)

connection.close()