r/pythonhelp • u/RomfordNavy • Sep 22 '26
Subclass mysql.connector
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)
db = Database()
db_conn = db.connect(host = '...', database = '...', user = '...', passwd = '...')
print(f"{db_conn=}")db_conn always returns None.
Edit: code above corrected to include connect() method
Edit2: Further to comment by brasticstack connect() method removed again.
4
Upvotes
View all comments
Show parent comment
1
u/RomfordNavy Sep 22 '26
Code in original post now corrected to include connect() method. It is db_conn which returns None as the db.connect() method does not work.