This is an automated archive.

The original was posted on /r/mysql by /u/Eigenlumen on 2023-08-12 21:20:13+00:00.


I can’t seem to figure out this error in my code. I keep loosing Mysql connection:

—try:

—conn = mysql.connector.connect(user=‘root’, password=‘####’,host=‘####’,database=‘###’)

—cursor = conn.cursor() \—-be except Exception:

—traceback.print_exc()

for i in range(0, len(listdates)):

—date= listdates[i]

—try:

------query = (“SELECT * FROM search WHERE time= %s;”, (date,))

------cursor.execute(query)

------row= cursor.fetchall()

—except Exception:

------traceback.print_exc()

The error is this: “error: mysql.connector.errors.OperationalError: 2055: Lost connection to MySQL server at ‘127.0.0.1:3306’, system error: Connection not available.”

I had no issue looping through executions in other parts of the code and I can execute this command if not in a loop. I don’t know what I am doing wrong. I tried closing the cursor inside the loop but that did not help.

Any help would greatly be appreciated as I have to add this last thing to a project and am pretty burnt out from coding. I must be making a very dumb syntax error somewhere.

Thanks for reading.