[DB-SIG] Scrollable cursors
Andy Dustman
adustman@comstar.net
Mon, 13 Mar 2000 14:54:28 -0500 (EST)
On Tue, 22 Feb 2000, Christopher Petrilli wrote:
> Cary Collett [cary@ratatosk.org] wrote:
> >
> > For me LIMIT is the big one:
> >
> > SELECT ... LIMIT 4 (return the first 4 results)
> > SELECT ... LIMIT 3,5 (return the 4th through 9th rows)
>
> Correct behaviour of scrollable cursors will get you this in a MUCH
> more advanced form :-)
Scrollable cursors are not (yet) part of the DB API spec. However, it
occurred to me in doing some MySQLdb updates that MySQL effectively has
scrollable cursors using mysql_data_seek(result, offset), where offset is
a relative offset. (Although, this is limited to clients that use
mysql_store_result(), which MySQLdb does, as opposed to
mysql_use_result(). Either way, the LIMIT SQL extension for MySQL will
reduce the number of rows which are send back to the client.)
So, are there any DB API interface which employ scrollable cursors to this
date? If not, I propose the following semantics:
cursor.seek(n) -- scrolls the cursor to row n, with the first row being 0.
If the database does not support seekable cursors, this method should not
be defined. If database cannot support seeking under current conditions,
it should raise NotSupportedError. (Similar to the cursor.rollback()
language)
Does this sound okay? The next release is not immininent, but I'd just as
soon not have to change it if I don't have to.
(Incidentally, the next version of MySQLdb will recognize when MySQL
supports transactions, and define commit() and rollback() accordingly.)
--
andy dustman | programmer/analyst | comstar.net, inc.
telephone: 770.485.6025 / 706.549.7689 | icq: 32922760 | pgp: 0xc72f3f1d
"Therefore, sweet knights, if you may doubt your strength or courage,
come no further, for death awaits you all, with nasty, big, pointy teeth!"