I have a python3 script that uses a global $CONN variable as a MySQL connection. But MySQL connection breaks automatically sometimes. Is there any time limit for MySQL connection in python3?
I have a python3 script that uses a global $CONN variable as a MySQL connection. But MySQL connection breaks automatically sometimes. Is there any time limit for MySQL connection in python3?
You can set the connection times as follow:
con.query('SET GLOBAL connect_timeout=28800')
con.query('SET GLOBAL wait_timeout=28800')
con.query('SET GLOBAL interactive_timeout=28800')
The numbers are in seconds, so 28800 seconds = 8 hours.
If you want to see the currently configured times, execute this query on the database:
SHOW VARIABLES LIKE '%timeout';