Chapter 4. Exception Handling
Any application that is used by multiple users in a production environment should have some level of exception handling implemented.
In this chapter, we will look at the following:
- Why errors and warnings are a programmer's friend
- The difference between errors and warnings
- The two main kinds of errors passed by MySQL for Python
- The six kinds of
DatabaseError
- How to handle errors passed to Python from MySQL
- Creating a feedback loop for the user, based on the errors passed
At the end of this chapter, we will use this information along with the knowledge from the preceding chapters to build a command-line program to insert, update, and retrieve information from MySQL and to handle any exceptions that arise while doing so.
Why ...
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.