[DB-SIG] perl-DBI like module for Python?

Stuart Bishop stuart.b at commonground.com.au
Wed May 26 08:02:45 EDT 2004


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


On 24/05/2004, at 4:57 PM, Mihai Ibanescu wrote:

> Hello,
>
> 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 the
> DB API document, but with the ability to change backend drivers on the 
> fly.

No.

The drivers have enough functionality that this extra layer is
generally not needed. The major desire for such a library
would be to standardize the parameter style used.

> Example: I have my application running against Postgres. I have to be 
> able to
> port it to Oracle too. Unfortunately, code that tries to catch
> DatabaseException will have to look for the cx_Oracle 
> DatabaseException, not
> for the postgres one.

The exceptions are most likely exposed through your connection object
(I think most the major drivers support this option now?).

try:
	cur = con.cursor()
	cur.excecute('select foo from bar')
except con.DatabaseException:
	print 'Oops!'


- --  
Stuart Bishop <stuart at stuartbishop.net>
http://www.stuartbishop.net/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (Darwin)

iD8DBQFAtIdrAfqZj7rGN0oRAupyAJ928Z2ZMeU/ukTYQYq07xOUna8CSgCdHYo0
6H4MLrRUZjhrTP0k50Y5E4A=
=KKkP
-----END PGP SIGNATURE-----




More information about the DB-SIG mailing list