[DB-SIG] perl-DBI like module for Python?
misa at redhat.com
Wed May 26 09:57:38 EDT 2004
On Tue, May 25, 2004 at 11:05:34PM +0200, M.-A. Lemburg wrote:
> Mihai Ibanescu wrote:
> >I am not sure if it was mentioned before on this list.
> >Is there a module that does what the perl DBI module does?
> >What I mean by that is: a top-level module that exposes the API defined in
> >DB API document, but with the ability to change backend drivers on the fly.
> >Example: I have my application running against Postgres. I have to be able
> >port it to Oracle too. Unfortunately, code that tries to catch
> >DatabaseException will have to look for the cx_Oracle DatabaseException,
> >for the postgres one.
> >This would be easily solved if a DBI module would provide the base classes
> >(for things like Database, Cursor, DatabaseException etc.) that the code
> >use, and a connect function that could specify the database driver to use
> >(postgres, cx_Oracle etc). Drivers would inherit their classes from this
> >top-level module.
> >jdbc/odbc do the same thing.
> >Is there such a thing out there?
> If you're looking for a true DBI kind of approach:
> * works with Oracle, MS SQL Server, SAP DB, PostgreSQL, etc. etc.
> * same API for all of these
> * same API on Windows, Unix, *BSD, AIX, etc. etc.
> * supported
> * under active development
Thanks for the pointer, will look into it.
> OTOH, the Python DB API provides a specification of how database
> modules should interface to the Python program. Since Python binds
> based on name, that comes very close to the DBI kind of approach
> as well.
> In any case, most work usually goes into porting the SQL
> layer of the application, not the interface layer beneath
> it. Porting from Postgres to Oracle is not as hard at
> the interface level, but you'll find that porting the
> SQL concepts can be very time consuming.
I know :-) I chose postgres and Oracle as an example. In my case I have to use
two different database modules for Oracle - cx_Oracle and DCOracle. So the SQL
is mostly the same (except that DCOracle implements the DB API v1.0 so there
are some intricacies there).
Thanks for your suggestion.
More information about the DB-SIG