Mysql
 sql >> Database >  >> RDS >> Mysql

python pymysql.err.OperationalError:(2013, "Connessione persa al server MySQL durante la query")

spero che possa aiutare:

while True:  #it works until the data was not saved
    try:
        with connection.cursor() as cursor:


            print ('saving company details to db')
            cursor.execute("""INSERT INTO company(
                                                   companyname,address,city,pincode,website) 
                                               VALUES (%s, %s, %s, %s, %s)""",
                                               (companyname, companyaddress, companycity, 
                                                companypostalcode, companywebsite))
        connection.commit()
        break
    except OperationalError:
        connection.ping(True)
print ("Company Data saved")

Puoi anche visualizzare domanda con l'utilizzo del pool di connessioni

oppure leggi il fonte