[DB-SIG] Experiences with DB-API2.0
Andy Dustman
andy@dustman.net
20 Jun 2002 09:47:51 -0400
On Thu, 2002-06-20 at 07:54, Tom Jenkins wrote:
> On Thu, 2002-06-20 at 07:49, Horst Herb wrote:
> > We thought DB-API was a great idea. That is, until we tried....:
> >
> > 1.) Connection strings incompatible between the 3 "most popular" Postgres
> > adatpters - easy enough to fix, just a few "if....then..else"
> > However, becomes tedious if you have hundreds of connections :-((
Perhaps it would have been better, in retrospect, to require arguments
similar to MySQLdb, i.e.
connect(host=None, user=None, password=None, **kwargs)
and then the connect would construct a DSN or whatever from those
arguments, including any keyword arguments that define non-standard
things.
I will admit to arguing for the current situation, however.
> > 2.) Returned date formats incompatible despite all of them using mxDateTime
I have trouble understanding why this should be, if they are all using
mxDateTime. Do they not all return DateTime instances?
> Same thing here Horst. Also exception handling is difficult as each has
> their own exception types.
This should be fixed somewhat by the recent optional extensions to
DB-API v2 which add the exceptions to the connection and cursor
instances. Even then, MySQLdb.IntegrityError != psycopg.IntegrityError.
Would the solution be to have a standard DBException module which
defines these exceptions? These exceptions would need to be imported
into each database module (though not exported); I doubt they will ever
be "standard" exceptions (in the exceptions module). Since usually these
exceptions are raised in C code, that would require some implementation
work, although _mysql (the C portion of MySQLdb) already imports it's
exceptions from a separate module (_mysql_exceptions).
--
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