- Python & MySQL - Discussion
- Python & MySQL - Useful Resources
- Python & MySQL - Quick Guide
- Python & MySQL - Handling Errors
- Python & MySQL - Performing Transactions
- Python & MySQL - Using Joins
- Python & MySQL - Sorting Data
- Python & MySQL - Like Clause
- Python & MySQL - Where Clause
- Python & MySQL - Delete Records
- Python & MySQL - Update Records
- Python & MySQL - Select Records
- Python & MySQL - Insert Records
- Python & MySQL - Drop Tables
- Python & MySQL - Create Tables
- Python & MySQL - Select Database
- Python & MySQL - Drop Database
- Python & MySQL - Create Database
- Python & MySQL - Connect Database
- Python & MySQL - Environment Setup
- Python & MySQL - Overview
- Python & MySQL - Home
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Python & MySQL - Handpng Errors
There are many sources of errors. A few examples are a syntax error in an executed SQL statement, a connection failure, or calpng the fetch method for an already canceled or finished statement handle.
The DB API defines a number of errors that must exist in each database module. The following table psts these exceptions.
Sr.No. | Exception & Description |
---|---|
1 | Warning Used for non-fatal issues. Must subclass StandardError. |
2 | Error Base class for errors. Must subclass StandardError. |
3 | InterfaceError Used for errors in the database module, not the database itself. Must subclass Error. |
4 | DatabaseError Used for errors in the database. Must subclass Error. |
5 | DataError Subclass of DatabaseError that refers to errors in the data. |
6 | OperationalError Subclass of DatabaseError that refers to errors such as the loss of a connection to the database. These errors are generally outside of the control of the Python scripter. |
7 | IntegrityError Subclass of DatabaseError for situations that would damage the relational integrity, such as uniqueness constraints or foreign keys. |
8 | InternalError Subclass of DatabaseError that refers to errors internal to the database module, such as a cursor no longer being active. |
9 | ProgrammingError Subclass of DatabaseError that refers to errors such as a bad table name and other things that can safely be blamed on you. |
10 | NotSupportedError Subclass of DatabaseError that refers to trying to call unsupported functionapty. |
Your Python scripts should handle these errors, but before using any of the above exceptions, make sure your MySQLdb has support for that exception. You can get more information about them by reading the DB API 2.0 specification.
Advertisements