[DB-SIG] Problem with exception classes
mal at lemburg.com
Thu Apr 17 20:22:26 EDT 2003
Wichert Akkerman wrote:
> I've been using DB-API2 for a while now but have run into a few issues
> with respect to portability between different SQL backends. One of those
> is the paramstyle, which I'm happy to see might be addressed in DB-API3.
> However issue I ran into is exception classes: a lot of my code is
> passed a database connectino or a cursor and does not know which backend
> it is attached to. However since DB-API2 species that exception types
> can only be accesses directly from the driver module that means I can
> not perform any exception handling. At the moment I work around this
> by using a wrapper that copies the exception classes into the connection
> instance (inspired by the MySQLdb module, which does that as well).
> Is that something that would be useful to add to DB-API3 as well?
I guess this would be possible :-)
FWIW, mxODBC is exposing the exception
objects on the connection objects as well and it also provides
a .connection attribute on cursors, so passing around cursors
still let's you use exception handling.
Professional Python Software directly from the Source (#1, Apr 17 2003)
>>> Python/Zope Products & Consulting ... http://www.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
EuroPython 2003, Charleroi, Belgium: 68 days left
More information about the DB-SIG