MySQL Forums
Forum List  »  Connector/Python

fetchmany bug?
Posted by: Marcin B
Date: December 05, 2019 07:50AM

Hello!
I have a test table with 90 061 rows and I want to fetch rows in batches, so I want to use fetchmany:

cursor = cnx.cursor()
query = "select id from test_table"
cursor.execute(query)
for i in range(105):
rows = cursor.fetchmany(1000)
print("rows returned : {}".format(len(rows)))
if not rows:
break;


Using connector versions 8.0.12 and above, the code do not stops when there is no more rows in cursor, fetchmany returns continously the last row from the set:
(...)
rows returned : 1000
rows returned : 1000
rows returned : 1000
rows returned : 1000
rows returned : 1000
rows returned : 61
rows returned : 1
rows returned : 1
rows returned : 1
rows returned : 1
rows returned : 1
rows returned : 1

Using the same code with connector v 8.0.11 gets me expected result:
(...)
rows returned : 1000
rows returned : 1000
rows returned : 1000
rows returned : 1000
rows returned : 1000
rows returned : 1000
rows returned : 1000
rows returned : 61
rows returned : 0

Python 3.6, MySQL 5.7

Is this a bug?
Best
Marcin

Options: ReplyQuote


Subject
Written By
Posted
fetchmany bug?
December 05, 2019 07:50AM
December 05, 2019 08:00AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.