[DB-SIG] Optional DB API Extensions

M.-A. Lemburg mal@lemburg.com
Fri, 26 Oct 2001 16:57:23 +0200


Andy Dustman wrote:
> 
> On Fri, 2001-10-26 at 08:46, M.-A. Lemburg wrote:
> > Andy Dustman wrote:
> > >
> > > On Tue, 2001-10-23 at 11:04, M.-A. Lemburg wrote:
> > >
> > > >     Cursor Attribute .rownumber
> > >
> > > Now implemented in MySQLdb (was cursor._pos).
> > >
> > > >     Cursor Method .scroll(value[,mode='relative'])
> > >
> > > Currently I have cursor.seek() and cursor.tell(), which work as the file
> > > object methods.
> >
> > Hmm, not a bad idea... following the file interface here (except
> > that .tell() is already available through .rownumber).
> 
> Generally speaking, I think I prefer methods to read-only attributes.
> The Db-API interface of MySQLdb is written in Python, and I'd rather not
> have to deal with __setattr__/__getattr__ hooks if I don't have to. Plus
> it is arguably better practice for a user interface.

But didn't you write that you have the .rownumber implemented
already ?

Since this attribute only has to be updated whenever you use 
.fetch...() or .scroll(), there's really no need to have an 
extra method for it, well, IMHO.

After some more thinking I also found that I like .scroll() better than
.seek() and .tell(). The reason is that in database terms, cursors
"scroll", they don't "seek" ;-) (also, I like string arguments more
than hard-to-remember integer options).

What do you think -- should it be .seek() or .scroll() ?

> > > >    Cursor Attribute .messages
> > > >    Connection Attribute .messages
> 
> Similar, why not cursor.messages(), which returns a list of messages
> generates, and clears the list, and the same for connection.messages().

But exposing the plain lists should be very simple on DB API writers
and its also very useful for DB users that way, since they already know 
how to manipulate lists (we don't have to invent a new interface 
for these tasks).

-- 
Marc-Andre Lemburg
CEO eGenix.com Software GmbH
______________________________________________________________________
Consulting & Company:                           http://www.egenix.com/
Python Software:                        http://www.lemburg.com/python/