Python Glossary Русский

all Python 3sqlite3exception

sqlite3.InterfaceError

exceptions

Raised for misuse of the low-level SQLite C API; a subclass of sqlite3.Error, it usually indicates a bug in the sqlite3 module rather than in the database.

Syntax

sqlite3.InterfaceError

The one practical consequence: except sqlite3.DatabaseError will not catch it — InterfaceError sits beside DatabaseError in the hierarchy and their only common ancestor is sqlite3.Error, so a true catch-all for database problems must name Error. It rarely deserves a handler of its own: the fault is in how the C API was driven, not in your SQL or your data, so rewriting the query gets you nowhere.

Examples

import sqlite3
print(issubclass(sqlite3.InterfaceError, sqlite3.Error))          # → True
print(issubclass(sqlite3.InterfaceError, sqlite3.DatabaseError))  # → False
print(sqlite3.InterfaceError.__name__)                            # → InterfaceError
try: raise sqlite3.InterfaceError('мисюз C API')
except sqlite3.Error as e: print(type(e).__name__)                # → InterfaceError

See also

Open in the full glossarydocs.python.orgReport an inaccuracy