DB-API format string conventions

Craig Ringer craig at postnewspapers.com.au
Tue Dec 28 09:02:59 EST 2004


On Tue, 2004-12-28 at 21:16, Steve Holden wrote:

> > So ... anybody for a DB-API 2.1 with mandatory pyformat support and a
> > tuple dbmodule.paramstyles for supported styles?
>  
> Well, you can certainly put me down as supporting less variability in 
> allowed paramstyles, to the extent that it would allow much more 
> application portability.
> 
> However, you might not be aware that the reason that variability was 
> included in the first place is to allow Python module authors to take 
> advantage of features already available in the various underlying 
> database platform support code - Oracle, for example, already supports 
> numbered access (:1), and so on.

I'm not actually against the number of choices available, I'm just
concerned that there is currently no _single_ choice that can be
guaranteed to work, and that it's hard to identify all styles a given
API supports.

Of course, even if one does confine ones self strictly to what can be
guaranteed to work in the DB API, there are a multitude of differences
in database SQL syntax and extensions to worry about. That is an issue
any programmer will face - not just a Python DB-API 2.0 user, and I see
it as a separate issue. Tackling that would involve building a DB
abstraction layer like the various query builders available for Java - a
very interesting, but much bigger, job that I'm not even remotely
interested in looking at right now ;-)

> So be aware that you are asking the various module authors for 
> significant amounts of work, which may not be forthcoming under all 
> circumstances.

That's true, and something I'm keeping in mind. I'd be quite happy to
implement the required changes for modules I'm familar with to help with
that issue.

That said, if pyformat was chosen as the required style it might not be
too big a job at all. Many modules already support pyformat though not
all advertise the fact, and for them it may be as simple as bumping the
API version to 2.1 and adding a module-level var containing a tuple of
all supported styles.

> Also be aware that there have been various post-2.0 proposals for the DB 
> API, which you might want to look up on Google and fold in to the 
> current campaign.

Indeed. I went looking for proposals specifically related to argument
handling earlier, but still need to have a look for other API revision
proposals.

I thought it best to ask here to find out how much interest there would
be in clarifying the API and adding a required format style before going
ahead with actually writing a few patches and a draft PEP for comments.

--
Craig Ringer




More information about the Python-list mailing list