[DB-SIG] Experiences with DB-API2.0

Andy Dustman andy@dustman.net
21 Jun 2002 21:01:20 -0400


On Fri, 2002-06-21 at 15:31, M.-A. Lemburg wrote:
> Some examples which almost always need some way of tweaking:
> 
> * auto-increment or sequencing
> * blobs and other more esoteric data types like images and Unicode
> * for MySQL and non-SQL databases: sub-selects, joins, views, transactions
> * count()
> * select distinct
> * locking
> * transaction isolation
> * database, table and user creation
> * various limits on data types
> * syntax for defining data types
> * names of data types
> 
> and probably a dozen more.

I think this highlights that there are two separate portability issues.

1) Ability to execute queries on the database and return results

2) The queries themselves

DB-API does a good job, IMHO, on point 1, once you get a connection
object. If we were doing another version, I'd standardize connect by
ditching connection *strings* for connection *parameters* (host, user,
passwd are pretty universal) and keyword arguments for anything else.

DB-API doesn't do much for point 2, nor was it ever intended to. It
doesn't even require that SQL be passed to .execute. That, perhaps,
should be a job for the SQL-API, which doesn't exist, but could be an
additional layer on top of DB-API. Indeed, this could be a fairly
standard wrapper/proxy class for a connection object which is extended
as needed with mixins for various implementations (DB-API modules) which
actually constructs SQL statements.

I'm presently working on something along these lines and might have
something to show for it by OsCon 2002.

-- 
Andy Dustman         PGP: 0x930B8AB6
    @       .net     http://dustman.net/andy
"Cogito, ergo sum." -- Rene Descartes
"I yam what I yam and that's all what I yam." -- Popeye