DBAPI

Paul Boddie paul at boddie.net
Tue Apr 23 06:19:27 EDT 2002


John Goerzen <jgoerzen at complete.org> wrote in 
news:87adrvambl.fsf at complete.org:
> >
> > I have used things like JDBC for Java and DBI for Perl.  To me, DBAPI
> > for Python looks rather week.  For instance, if the code is to be
> > truly portable across databases, I'd have to check the paramstyle for
> > the driver and write each query 5 times!

I suppose you could always parameterize the parameter style. ;-) But I
think you have a valid point in this area.

> > Is there any "meta-DBAPI" module that I can use that would present me
> > with a standardized interface, and then (for instance) convert my
> > queries to whatever format the backend wants?

Someone did have some code to do more ambitious abstraction over
different database systems - search the DB-SIG mailing list archives
for more information. Bear in mind, however, that database-neutral
layers of all kinds (particularly those based on SQL) are non-trivial
to implement and it's arguably typical that many of those that get
started only get to cover about two or three different database
systems.

Andy Todd <andy47 at halfcooked.com> wrote in message news:<Xns91F975562E137andy47halfcookedcom at 203.109.252.31>...
>
> As far as I am aware there is no meta-DBAPI. In my experience when people  
> talk about standard database interfaces that enable them to write 
> portable code they haven't actually tried to write any. SQL isn't 
> standard so it is impossible to write database independent code for all 
> but the most trivial of applications.

Certain SQL standards do exist and it would be possible to write to
those and then have some kind of layer to translate the statements
into vendor-specific versions. If only database vendors adhered to the
standards...

[...]

> On the other hand it is very hard to write Python db modules that will 
> work in exactly the same way on several databases anyway. The example you 
> give of parameter style is a case in point, most Python db modules stick 
> close to the implementation in the supplied database libraries rather 
> than try and wrestle them into some abritrary standard.

Well, JDBC specifies an "arbitrary standard" and I don't think that
there's much need to complain about how it is now impossible to use
Proprietary Vendor Corporation's NonStandardParameterEncoding(TM) with
JDBC - most developers really don't want the "choice" that the vendors
give in this area. Moreover, the DB-API seems to confuse the issue
with its "Python-style" encodings, which I'm fairly sure is
responsible for part of the misunderstanding amongst certain
developers about what parameters are in SQL statements.

[...]

> For more detailed discussion may I suggest moving to the DB-SIG mailing 
> list, for details see - http://mail.python.org/mailman/listinfo/db-sig

See you there!

Paul



More information about the Python-list mailing list