I have the following function which is leaving connections open but I can't figure out why.
The Cursor class creates a python-generator type function, allowing me to iterate over millions of rows.
connection=MySQLdb.connect("", "", "", "",
cursorclass = MySQLdb.cursors.SSCursor)
cursor=connection.cursor()
cursor.execute("select id, ...", (profile_id, ...))
try:
for row in cursor.fetchall():
yield row
except:
pass
finally:
connection.close()
Where am I going wrong?
Asked by Adders
(175 rep)
Aug 30, 2018, 01:40 PM
Last activity: Jul 5, 2025, 04:08 PM
Last activity: Jul 5, 2025, 04:08 PM