[DB-SIG] Database Abstraction in Python
chris at cogdon.org
Sat Apr 16 00:34:48 CEST 2005
On Apr 15, 2005, at 15:11, Tom Haddon wrote:
> Hi Marc-Anderson,
> Thanks for the response. It sounds like you're saying that the
> practicalities of database abstraction make its implementation
> un-pythonic. I'm not sure I fully agree, but I take the point that if
> you want get the most out of a database, you probably want to write
> DB-specific code. At the same time, I think the whole point of
> database abstraction is more from a code re-use/re-factoring
> standpoint, and that the implicit trade off with features/performance
> is in some cases worth it.
> Appreciate the input though.
There's one more thing that Marc said I think you missed:
Any abstraction mechanism that tries to be TOO general, coping with
every application type, and every database type, will end up supporting
only such a minimal set of database operations that it becomes very,
Instead, write a database abstractor that is specific for your
application, or group of applications, and then you just need to write
the underlying interface between the abstraction layer and the database
connector for every supportable database. This way, it's 'dead simple'
to port your application to a new database, since all the 'required
operations' are effectively self-documenting.
I've explored the issue enough myself that makes me believe that "any
attempt to create a abstraction system that covers all application
requirements AND all database implementations is doomed to failure, or
Now... what might be interesting is a collection of libraries,
functions, classes and mixins that makes the task of creating such
abstraction layers easy. For example, when I've written such layers for
various applications, I've needed functions A B C for Postgresql, and B
C D for Mysql... some overlap, but not much. The 'workhorse' databases
are going to be very different, too, perhaps very little overlap.
But... there are things that seem to recur over and over.
Food for thought, but... I'm not too hungry right now.
("`-/")_.-'"``-._ Chris Cogdon <chris at cogdon.org>
. . `; -._ )-;-,_`)
(v_,)' _ )`-.\ ``-'
_.- _..-_/ / ((.'
((,.-' ((,/ fL
More information about the DB-SIG