[CONPY-276] Buffered cursor doesn't work after connection was closed Created: 2023-12-01  Updated: 2023-12-20  Resolved: 2023-12-20

Status: Closed
Project: MariaDB Connector/Python
Component/s: DBAPI 2.0
Affects Version/s: 1.1.8
Fix Version/s: 1.1.9

Type: Bug Priority: Major
Reporter: Georg Richter Assignee: Georg Richter
Resolution: Fixed Votes: 0
Labels: None

Python Version: 3.8+

 Description   

When retrieving large datasets with a buffered cursor, it makes sense to close the connection immediately since it will not be used anymore, all data was read from server and processing data inside the application will take a lot of time.

This works fine with PyMySQL:

>>> import pymysql
>>> conn=pymysql.connect(user="root")
>>> cursor=conn.cursor()
>>> cursor.execute("select 1 union select 2")
2
>>> conn.close()
>>> cursor.fetchone()
(1,)
>>> cursor.fetchone()
(2,)

While MariaDB Connector/Python throws an exception, since the connection was closed:

>>> import mariadb
>>> conn=mariadb.connect(user="root")
>>> cursor=conn.cursor()
>>> cursor.execute("select 1 union select 2")
>>> conn.close()
>>> cursor.fetchone()
Traceback (most recent call last):
...
mariadb.ProgrammingError: Invalid connection or not connected
>>>

This issue was intially reported by a member of PUG Berlin (Sorry, I don't remember the name)


Generated at Thu Feb 08 03:31:34 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.