[DB-SIG] return value of fetchone (DBAPI 2.0)
Stefan Fleiter
sf.lists at web.de
Tue Aug 5 18:26:15 EDT 2003
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.
Con someone please clarify on this?
Thanks in advance,
Stefan Fleiter
More information about the DB-SIG
mailing list