mardi 21 juin 2016

What happens if I don't close a mysql connection and opens another?

cnx = mysql.connector.connect(user="root", password="pass", host="127.0.0.1", database="db")
cursor = cnx.cursor()
return cursor, cnx

Lets say I open a connection like the above, and make a select query cursor.execute(selectquery) and use cursor.fetchall() to get the data.

If I don't cnx.close() and cursor.close() what will happen when I continuously open and do select queries like this?

Will the connection stay open? Or are there any "garbage patrol" that can see it's not getting used?

Aucun commentaire:

Enregistrer un commentaire