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 also ...
Get MySQL for Python now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.