From: <gh...@gh...> - 2003-12-02 09:04:44
|
Mike C. Fletcher wrote: > I'm working on making my dbapi wrapper capable of detecting a situation > where the database has gone down while a connection is held. i.e. this > sequence... > > c = driver.connect() > <database goes down, (and comes back up again, though that's > irrelevant here)> > c.cursor.execute( x ) > > Now, what I would expect to be raised is: > > OperationalError [...] I agree with you. However, all we get from the PostgreSQL side in an error case are PGRES_BAD_RESPONSE, PGRES_NONFATAL_ERROR or PGRES_FATAL_ERROR. Currently, in case of PGRES_NONFATAL_ERROR we raise a ProgrammingError, while it could be either a ProgrammingError or an OperationalError. If we wanted to distinguish between these two, we'd need to parse the PostgreSQL error strings, though. I'm personally against implementing this, because this whole error message business looks like a mess to me in older PostgreSQL versions. PostgreSQL 7.4 and later, however, now have a reasonable error message API, with error codes [1] that we could easily map to the corresponding DB-API exception classes. -- Gerhard [1] http://www.postgresql.org/docs/current/interactive/errcodes-appendix.html |