fetchone() does not follow pep-0249

Bug #454782 reported by Mike Bayer
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MySQL Connector/Python
Fix Released
Medium
Geert JM Vanderkelen

Bug Description

the fetchone() method of cursor raises "InterfaceError: Fetched all rows already." when called with no further rows remaining. It should be returning None as per pep-0249:

  .fetchone()
    Fetch the next row of a query result set, returning a
    single sequence, or None when no more data is
    available. [6]

Test case:

    from mysql import connector

    conn = connector.connect(user='scott', password='tiger', database='test', host='localhost')

    cursor = conn.cursor()
    cursor.execute("select 1")

    # succeeds
    assert cursor.fetchone() == (1,)

    # fails
    assert cursor.fetchone() is None

Tags: cursor pep249

Related branches

Revision history for this message
Geert JM Vanderkelen (geertjmvdk) wrote :

Thanks for this report!
This will come in next push where I changed how rows are fetched.

There will be exception raised, but that's only when for example the connection died or no protocol was said. Things like that.

Changed in myconnpy:
assignee: nobody → Geert JM Vanderkelen (geertjmvdk)
importance: Undecided → Medium
status: New → Confirmed
tags: added: cursor pep249
Changed in myconnpy:
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.