MySQL Connector/Python Developer Guide

10.2.28 MySQLConnection.reconnect() Method

Syntax:

cnx.reconnect(attempts=1, delay=0)

Attempt to reconnect to the MySQL server.

The argument attempts specifies the number of times a reconnect is tried. The delay 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.