The question says everything. How can I check if my MySQL connection is closed in Python?
I'm using MySQLdb, see http://mysql-python.sourceforge.net/
open attribute will tell you whether the connection has been explicitly closed or whether a remote close has been detected.
The close() / mysqli_close() function closes a previously opened database connection.
The Connection.open
field will be 1
if the connection is open and 0
otherwise. So you can say
if conn.open: # do something
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With