Does anyone know if it is necessary to check whether a mysql.connector is connected each time I reuse ti before running any SQL statements or is this something which is already built-in to mysql.connector? Do I need to check for connection using db.is_connected() and write some retry routine.
This is a WSGI webserver so my understanding is that there will only ever be one request/thread at a time. Connection pooling has been suggested elsewhere but I am unclear as to whether that is necessary and/or appropriate for a WSGI webserver.
On a related subject, any idea what I am doing wrong when trying to subclass mysql.connector like this:
import mysql.connector
class Database(mysql.connector.MySQLConnection):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
def connect(self, *args, **kwargs):
super().connect(*args, **kwargs)
db = Database()
db_conn = db.connect(host = '...', database = '...', user = '...', passwd = '...')
print(f"{db_conn=}") # <- returns None
db_conn always returns None.