MySQL Connector/Python Developer Guide / ... / Connector/Python API Reference / connection.MySQLConnection Class / MySQLConnection.reconnect() Method
Syntax:
cnx.reconnect(attempts=1, delay=0)Attempt to reconnect to the MySQL server.
The argumentattempts specifies the number of times a reconnect is tried. Thedelay argument is the number of seconds to wait between each retry.
You might set the number of attempts higher and use a longer delay when you expect the MySQL server to be down for maintenance, or when you expect the network to be temporarily unavailable.