MySQL Connector/Python Developer Guide / ... / Connector/Python API Reference / connection.MySQLConnection Class / MySQLConnection.ping() Method
Syntax:
cnx.ping(reconnect=False, attempts=1, delay=0)Check whether the connection to the MySQL server is still available.
Whenreconnect is set toTrue, one or moreattempts are made to try to reconnect to the MySQL server, and these options are forwarded to thereconnect()>method. Use thedelay argument (seconds) if you want to wait between each retry.
When the connection is not available, anInterfaceError is raised. Use theis_connected() method to check the connection without raising an error.
RaisesInterfaceError on errors.