[DB-SIG] Remaining issues with DB API 2.0

M.-A. Lemburg mal@lemburg.com
Mon, 29 Mar 1999 10:52:15 +0200


Andy Dustman wrote:
> 
> > > >        · Naming of some of the values for the .paramstyle attribute:
> > > >          Andy Dustman proposed to change "percent" and "xpercent"
> > > >          to "format" and "dictformat". I prefer "pyformat" instead of
> > > >          "dictformat"...
> > >
> > > format and pyformat seem fine.
> > > [ and it is in the spec like this ]
> > >
> > > The part about multiple paramstyles should not be included. A database
> > > should take just one style and be done with it. Higher levels can
> > > perform the appropriate mappings.
> >
> > Andy ?
> 
> Yeah, sure. There's no database that supports multiple styles at this
> time, though the new MySQLdb could, since it is using the % string
> operator anyway. Maybe I'll slip that in as a separate method or
> something.

Ok.

> > Hmm, I guess you've got a point there. I'll make the parameter
> > list a guideline then (this part of the spec isn't going to be
> > portable anyway...). Still, I'll leave the keyword stuff in --
> > people should start using keyword based functions in C more
> > often...
> 
> I make pretty good use of keyword parameters in the underlying _mysql
> module, i.e.
> 
> c=_mysql.connect(host, user, passwd, db, port, unix_socket, client_flag)
> 
> where all those are keyword parameters which mostly default to NULL.
> Usually I can get away with:
> 
> c=_mysql.connect(passwd='pwd')
> 
> The current positional parameters really sorta cramp my style a bit,
> though I have worked around it. If it were legal for me to define my
> connect() to only take keyword parameters, I'd be happy, though I need to
> renamed the password parameter somehow; my design for the C module has
> been to keep it very close to the C MySQL API. Well, I'll work it out.

It should be legal. The spec now says:

"""
connect(parameters...) 
  Constructor for creating a connection to the database. 
  Returns a Connection Object. It takes a number of parameters
  which are database dependent. [1] 
"""

with the footnote pointing to a set of parameters that can be used
as guideline (either positional, keyword based or both).

-- 
Marc-Andre Lemburg                               Y2000: 277 days left
---------------------------------------------------------------------
          : Python Pages >>> http://starship.skyport.net/~lemburg/  :
           ---------------------------------------------------------