[DB-SIG] Database API clarifications

Tod Olson Tod Olson <ta-olson@uchicago.edu>
Mon, 02 Feb 1998 17:34:02 -0600


>>>>> "M" == M -A Lemburg <lemburg@uni-duesseldorf.de> writes:

M> Tod Olson wrote:
>> 
>> [adding cursor.nextset()]
>> 
>> How about cursor.nextset() returns self.  Two
>> benefits:
>> 
>> - Allows cursor.nextset().fetchall(), which is nice for interactive
>> typing.
>> 
>> - Works nicely if the database-API evolves to treat result sets as
>> objects.

M> That's a religous topic :-) just like many people would like to see
M> list.sort() return list and not None. We could specify it to return
M> a truth value (None is false, 1 and self are true). That leaves
M> enough space for future extensions. Objections ?

So much for slipping that in under the radar.  ;) More to the point, I
was thinking of self because it's not just a truth value, it is a
value that the programmer can use immediately.  Anyhow, an unspecified
truth value seems reasonable.

M> cursor.nextset() will have to switch to the next result set in any
M> case, so the latter is more appropriate. You can write it like this:

M>         cursor.execute(big_query)
M> 	while 1:
M> 	        cursor.fetchall()
M>         	if not cursor.nextset():
M> 			break

M> without having to copy anything (Python's idiom for do {...} while
M> (...)).

Hmm, that does remove some of the advantage to cursor.nextset()
returning self.  But it is the idiom.

WRT cursor.nextset() switching to the next result set: in Sybase, at
least, this only happens after all of the rows from the current result
set have been fetched.  More precisely, I have found no way to cancel
the remainder of the current result set and start up with the next, I
have to cancel the whole command.

This being the case, for Sybase it may be appropriate to raise an
exception if the programmer attempts to skip to the next result set
before processing all the rows of the current one.  If you disagree,
perhaps the database-API (c|sh)ould leave this particular behavior
undefined until the db-sig has more experience with multiple result
sets.

Tod A. Olson                        "How do you know I'm mad?" said Alice.
ta-olson@uchicago.edu               "If you weren't mad, you wouldn't have
The University of Chicago Library    come here," said the Cat.


_______________
DB-SIG  - SIG on Tabular Databases in Python

send messages to: db-sig@python.org
administrivia to: db-sig-request@python.org
_______________