Python not so long ago studied, there is a question...
Is it possible to create a DB connection (MySQL) in all Python files Telegram Bot? (In this case, three files)
Currently struggling with this:
pymysql.err.OperationalError: (2013, 'Lost connection to MySQL server during query')
Struggling like so:
# if the connection was lost, then it reconnects
db.query('SET GLOBAL connect_timeout=86000')
if db.open is False:
max_try = 15
tryt = 0
while db.open is False:
if tryt < max_try:
db.ping() # autoreconnect is true by default
db = pymysql.connect(host='localhost', ... the connection.
And so in three files.
Thanks for any help, hint!