[DB-SIG] PEP249 - Proposed change to DB-API 2.0

Harri Pasanen harri.pasanen@trema.com
Fri, 27 Apr 2001 09:44:23 +0200


"M.-A. Lemburg" wrote:
> 
> > [Making the DB API interface handle multiple paramstyles]
> >
> > > Sybase only supports the ? place holder.
> > >
> > > I am not sure how feasible this is, but maybe a (simple) SQL parser
> > > could be used to support any placeholder style which would then be
> > > transformed into the native style to interface with the database API.
> >
> > That would work for me too. Frankly, I dont see why the API should not
> > support /all/ styles. The API writer codes the style the backend database
> > most easily supports, then helper functions (supplied by the python-core
> > libraries, for example) turn all the other styles into that style for you.
> >
> > The /user/ of the DB-API should not have to care what the 'native' style
> > is, since there is a deterministic conversion between all styles (I
> > think).
> >
> > However it is done, I should not have to rewrite code just because I slot
> > in a different API.
> 
> That's easy for you to say ;-) However, your small benefit will cost a
> lot of module writers a lot of work and sometimes it may even
> not be possible getting this right.
> 
> To support all the different styles, the module writer would have
> to parse the SQL statement to figure out how to map the paramstyle
> used in there to the native one. Writing an SQL parser is not
> necessarily possible though, since there are so many different
> SQL variations in use out there. I'm not even talking about quoting
> rules here ;-)
> 
> If you really care about being able to change database interfaces,
> then you'll have to write an abstraction for your interface anyway,
> so why put the burden on the DB API writer here ? (This only makes
> it harder for interface writers to come up with code which can
> be considered DB API compatible.)
> 

How about specifying a single 'python meta' -style.  So the module
writers would support the database native format, and the Python DB-Api
format, from which a conversion to native format would exist.  I spent
maybe 2 minutes thinking about it, so maybe this is not feasible, just a
thought...

-Harri