[DB-SIG] return value of fetchone (DBAPI 2.0)
M.-A. Lemburg
mal at lemburg.com
Tue Aug 5 21:20:21 EDT 2003
Stefan Fleiter wrote:
> Hi!
>
> I had a discussion by private mail with Stuart Bishop about the
> return value of fetchone() of the DBAPI 2.0.
>
> In his UnitTest (http://zen.freezope.org/Software/DBAPI20TestSuite/)
> it is assumed, that
> 'cursor.fetchall should return an empty list if '
> 'a select query returns no rows'.
>
> In http://www.python.org/peps/pep-0249.html,
> you can read in the paragraph specifying fetchone():
> An Error (or subclass) exception is raised if the previous
> call to executeXXX() did not produce any result set or no
> call was issued yet.
>
> Mr. Bishop writes:
> > I'm pretty certain the existing implementation is correct. There
> > is a difference between returning no result set and an empty one.
> > So .fetchall() after .execute('update ...') may raise an exception,
> > but .fetchall() after .execute('select * from foo where 0 = 1')
> > returns an empty list.
>
> I think the pep does not state this and should really be more clear
> regarding this issue.
>
> One thing that comes to my mind now is, that with Oracle and the
> "returning clause" almost every statement, including updates can produce
> a result.
>
> Can someone please clarify on this?
Not sure what you want clarified. Stuart is correct and the
db-api spec. is clear on this as well.
--
Marc-Andre Lemburg
eGenix.com
Professional Python Software directly from the Source (#1, Aug 05 2003)
>>> Python/Zope Products & Consulting ... http://www.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
________________________________________________________________________
More information about the DB-SIG
mailing list