Catching different types of exceptions

It is typically best practice to process different types of exceptions with different policies. This applies not only to database programming, but to software development in general. Exceptions can be caught with a generic except clause for simpler implementations, but more complex programs should process exceptions by type.

Note

In Python, there are 36 built-in exceptions and 9 built-in warnings. It is beyond the scope of this book to go into them in detail, but further discussion on them can be found online.

For exceptions see:

http://python.about.com/od/pythonstandardlibrary/a/lib_exceptions.htm

For warnings visit:

http://python.about.com/od/pythonstandardlibrary/a/lib_warnings.htm

The Python documentation ...

Get MySQL for Python now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.