pymysqlerrProgrammingError Cursor closed
This error occurs when you try to execute a query on a closed cursor object in the PyMySQL module. A cursor object is used to traverse the records returned from a query and is closed automatically after the query execution is complete.
To avoid this error, make sure that you are not trying to execute a query on a closed cursor object. You can check if the cursor is closed using the following code:
if not cursor:
cursor = connection.cursor()
If the cursor is closed, you can create a new cursor object and execute the query again. Alternatively, you can use a context manager to automatically close the cursor after the query execution is complete:
with connection.cursor() as cursor:
cursor.execute(query)
# process the results
``
原文地址: https://www.cveoy.top/t/topic/hhLS 著作权归作者所有。请勿转载和采集!