MySQL Connector/Python Developer Guide / ... / Connector/Python API Reference / connection.MySQLConnection Class / MySQLConnection.connected Property
Reports whether the connection to MySQL Server is available.
This read-only property checks whether the connection to MySQL is available using theping() method; but unlikeping(),connected returnsTrue when the connection is available, andFalse otherwise.