[DB-SIG] PEP 249

M.-A. Lemburg mal at egenix.com
Wed Nov 11 10:28:42 CET 2009

Sergey Shepelev wrote:
> Hello.
> Cursor objects.
> Regarding .fetch* methods family when there are no more rows.
> It is clearly specified that .fetchone() must return None and
> .fetchmany() must return empty sequence.
> But for .fetchall() it is unspecified.

.fetchall() should return an empty list.

> Now there is this myconnpy pure Python DB-API implementation for MySQL
> and its cursor.fetchall() returns None.
> https://bugs.launchpad.net/myconnpy/+bug/480360
> Conformance with fetchmany seems good to me. What is official answer on this?

The spec is not as clear in this respect as for .fetchmany(),
but since you can use .fetchmany() and .fetchall() interchangeably
on the cursor, the same logic applies to both of them:


            Fetch the next set of rows of a query result, returning a
            sequence of sequences (e.g. a list of tuples). An empty
            sequence is returned when no more rows are available.


            Fetch all (remaining) rows of a query result, returning
            them as a sequence of sequences (e.g. a list of tuples).
            Note that the cursor's arraysize attribute can affect the
            performance of this operation.

Marc-Andre Lemburg

Professional Python Services directly from the Source  (#1, Nov 11 2009)
>>> Python/Zope Consulting and Support ...        http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ...             http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/

::: Try our new mxODBC.Connect Python Database Interface for free ! ::::

   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
    D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
           Registered at Amtsgericht Duesseldorf: HRB 46611

More information about the DB-SIG mailing list