- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Database Handling Errors in Python
There are many sources of errors. A few examples are a syntax error in an executed SQL statement, a connection failure, or calling 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 lists these exceptions.
|Sr.No.||Exception & Description|
Used for non-fatal issues. Must subclass StandardError.
Base class for errors. Must subclass StandardError.
Used for errors in the database module, not the database itself. Must subclass Error.
Used for errors in the database. Must subclass Error.
Subclass of DatabaseError that refers to errors in the data.
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.
Subclass of DatabaseError for situations that would damage the relational integrity, such as uniqueness constraints or foreign keys.
Subclass of DatabaseError that refers to errors internal to the database module, such as a cursor no longer being active.
Subclass of DatabaseError that refers to errors such as a bad table name and other things that can safely be blamed on you.
Subclass of DatabaseError that refers to trying to call unsupported functionality.
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.
- Handling errors in SAP GUI Scripting code
- In MySQL, how can we declare a handler while handling errors?
- Handling system failure, database corruption in SAP HANA
- Precision Handling in Python
- Are Python Exceptions runtime errors?
- Handling missing keys in Python dictionaries
- What is exception handling in Python?
- URL handling Python modules (urllib)
- Errors in C/C++
- PHP Errors in PHP7
- Difference between Compile Time Errors and Runtime Errors in C Program
- Database Connection in Python
- Disconnecting Database in Python
- Errors within Perl Modules