[DB-SIG] Abstraction layer confusion,
ULA (was Re: Database Abstraction in Python)
James Gardner
james at pythonweb.org
Mon Apr 18 19:52:37 CEST 2005
Hi All,
In developing PDBC (the web.database module) I decided there were 5
levels of database abstraction so perhaps we can agree on naming them
like this:
Driver
DB-API
User Level API
Portability Layer
Object Relational Mapper
The driver is whatever libraries are used to connect to the database at
the lowest level. The DB-API 2.0 wraps the driver functionality to allow
low level database access for full control via SQL (perhaps with some
sensible type conversions). The user level API wraps up the DB-API
functionality into an easier to use form but doesn't abstract the
database functionality, only the API. The portability layer provides
database abstraction in both SQL and type conversions so that code works
identically on all supported databases. The object relational mapper
maps Python objects to SQL relationships so that no SQL is necessarily
needed.
To the best of my knowledge PDO, PyDAL, adodb are what I would describe
as user level APIs that is they simply wrap the DB-API methods in a more
convenient and standard form. SQLObject is an Object Relational Mapper.
The only portability layer I know of is my own. That is, an API that
behaves EXACTLY the same with EXACTLY the same SQL commands on all
supported databases by making a compromise between features and
portability (regardless of whether we agree this is actually the best
approach!)
It sounds like what is needed then is a DB-API with slightly less
flexibility left to the implementor which takes into account any changes
like the adoption of the datetime module and perhaps support for a
reduced number of parameter types, tighter use of connection parameters
etc. Are we also agreeing we need a user level API, perhaps similar to
PDO to be included as part of the standard library?? If so, would we
also include the database drivers themselves to provide database
functionality out of the box? Is there no general desire to work on a
portability layer or object relational mapper to be included in the
standard library?
Cheers,
James
More information about the DB-SIG
mailing list