The only thing preventing me from saying this is a really good idea is whether it's sensible Python practice. Somebody (me?!) needs to do some research about whether injecting extra base classes like this is frowned on. I suspect it won't work in general (e.g. C-wrapped classes), but I don't know.

If we can guarantee it works for all database exceptions, then it's a good idea.

We can't use this. It is not possible to assign to __bases__ in new-style classes, every exception class should be derived from Exception and in Python 2.5, Exception became a new-style class. So the method touted in the above link won't work in 2.5.