@@ -813,7 +813,7 @@ Connection Objects
813
813
*name *, and reopen *name * as an in-memory database based on the
814
814
serialization contained in *data *. Deserialization will raise
815
815
:exc: `OperationalError ` if the database connection is currently involved
816
- in a read transaction or a backup operation. :exc: `DataError ` will be
816
+ in a read transaction or a backup operation. :exc: `OverflowError ` will be
817
817
raised if ``len(data) `` is larger than ``2**63 - 1 ``, and
818
818
:exc: `DatabaseError ` will be raised if *data * does not contain a valid
819
819
SQLite database.
@@ -844,7 +844,7 @@ Cursor Objects
844
844
:ref: `placeholders <sqlite3-placeholders >`.
845
845
846
846
:meth: `execute ` will only execute a single SQL statement. If you try to execute
847
- more than one statement with it, it will raise a :exc: `.Warning `. Use
847
+ more than one statement with it, it will raise a :exc: `ProgrammingError `. Use
848
848
:meth: `executescript ` if you want to execute multiple SQL statements with one
849
849
call.
850
850
@@ -1098,14 +1098,20 @@ Blob Objects
1098
1098
Exceptions
1099
1099
----------
1100
1100
1101
+ The exception hierarchy is defined by the DB-API 2.0 (:pep: `249 `).
1102
+
1101
1103
.. exception :: Warning
1102
1104
1103
- A subclass of :exc: `Exception `.
1105
+ This exception is not currently raised by the ``sqlite3 `` module,
1106
+ but may be raised by applications using ``sqlite3 ``,
1107
+ for example if a user-defined function truncates data while inserting.
1108
+ ``Warning `` is a subclass of :exc: `Exception `.
1104
1109
1105
1110
.. exception :: Error
1106
1111
1107
- The base class of the other exceptions in this module. It is a subclass
1108
- of :exc: `Exception `.
1112
+ The base class of the other exceptions in this module.
1113
+ Use this to catch all errors with one single :keyword: `except ` statement.
1114
+ ``Error `` is a subclass of :exc: `Exception `.
1109
1115
1110
1116
.. attribute :: sqlite_errorcode
1111
1117
@@ -1121,34 +1127,60 @@ Exceptions
1121
1127
1122
1128
.. versionadded :: 3.11
1123
1129
1130
+ .. exception :: InterfaceError
1131
+
1132
+ Exception raised for misuse of the low-level SQLite C API.
1133
+ In other words, if this exception is raised, it probably indicates a bug in the
1134
+ ``sqlite3 `` module.
1135
+ ``InterfaceError `` is a subclass of :exc: `Error `.
1136
+
1124
1137
.. exception :: DatabaseError
1125
1138
1126
1139
Exception raised for errors that are related to the database.
1140
+ This serves as the base exception for several types of database errors.
1141
+ It is only raised implicitly through the specialised subclasses.
1142
+ ``DatabaseError `` is a subclass of :exc: `Error `.
1143
+
1144
+ .. exception :: DataError
1145
+
1146
+ Exception raised for errors caused by problems with the processed data,
1147
+ like numeric values out of range, and strings which are too long.
1148
+ ``DataError `` is a subclass of :exc: `DatabaseError `.
1149
+
1150
+ .. exception :: OperationalError
1151
+
1152
+ Exception raised for errors that are related to the database's operation,
1153
+ and not necessarily under the control of the programmer.
1154
+ For example, the database path is not found,
1155
+ or a transaction could not be processed.
1156
+ ``OperationalError `` is a subclass of :exc: `DatabaseError `.
1127
1157
1128
1158
.. exception :: IntegrityError
1129
1159
1130
1160
Exception raised when the relational integrity of the database is affected,
1131
1161
e.g. a foreign key check fails. It is a subclass of :exc: `DatabaseError `.
1132
1162
1133
- .. exception :: ProgrammingError
1163
+ .. exception :: InternalError
1134
1164
1135
- Exception raised for programming errors, e.g. table not found or already
1136
- exists, syntax error in the SQL statement, wrong number of parameters
1137
- specified, etc. It is a subclass of :exc: `DatabaseError `.
1165
+ Exception raised when SQLite encounters an internal error.
1166
+ If this is raised, it may indicate that there is a problem with the runtime
1167
+ SQLite library.
1168
+ ``InternalError `` is a subclass of :exc: `DatabaseError `.
1138
1169
1139
- .. exception :: OperationalError
1170
+ .. exception :: ProgrammingError
1140
1171
1141
- Exception raised for errors that are related to the database's operation
1142
- and not necessarily under the control of the programmer, e.g. an unexpected
1143
- disconnect occurs, the data source name is not found, a transaction could
1144
- not be processed, etc. It is a subclass of :exc: `DatabaseError `.
1172
+ Exception raised for `` sqlite3 `` API programming errors,
1173
+ for example supplying the wrong number of bindings to a query,
1174
+ or trying to operate on a closed :class: ` Connection `.
1175
+ `` ProgrammingError `` is a subclass of :exc: `DatabaseError `.
1145
1176
1146
1177
.. exception :: NotSupportedError
1147
1178
1148
- Exception raised in case a method or database API was used which is not
1149
- supported by the database, e.g. calling the :meth: `~Connection.rollback `
1150
- method on a connection that does not support transaction or has
1151
- transactions turned off. It is a subclass of :exc: `DatabaseError `.
1179
+ Exception raised in case a method or database API is not supported by the
1180
+ underlying SQLite library. For example, setting *deterministic * to
1181
+ :const: `True ` in :meth: `~Connection.create_function `, if the underlying SQLite library
1182
+ does not support deterministic functions.
1183
+ ``NotSupportedError `` is a subclass of :exc: `DatabaseError `.
1152
1184
1153
1185
1154
1186
.. _sqlite3-blob-objects :
0 commit comments