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

M.-A. Lemburg mal at egenix.com
Wed May 26 10:43:48 EDT 2004

Anthony Tuininga wrote:
 > Stuart Bishop wrote:
> On 24/05/2004, at 4:57 PM, Mihai Ibanescu wrote:
>>>> 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!'
>> Huh? My reading of the DB API says that the exceptions are defined at 
>> the __MODULE__ level, not the __CONNECTION__ level. Or am I missing 
>> something??? Please inform me!

This is one of the optional DB API extensions:

     Connection Attributes .Error, .ProgrammingError, etc.

         All exception classes defined by the DB API standard should be
         exposed on the Connection objects are attributes (in addition
         to being available at module scope).

         These attributes simplify error handling in multi-connection

         Warning Message: "DB-API extension connection.<exception> used"

See the Optional DB API Extensions section.

Marc-Andre Lemburg

Professional Python Services directly from the Source  (#1, May 26 2004)
 >>> Python/Zope Consulting and Support ...        http://www.egenix.com/
 >>> mxODBC.Zope.Database.Adapter ...             http://zope.egenix.com/
 >>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
EuroPython 2004, Göteborg, Sweden                           11 days left

::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! ::::

More information about the DB-SIG mailing list