@@ -681,7 +681,7 @@ Cursor Objects
681
681
:ref: `placeholders <sqlite3-placeholders >`.
682
682
683
683
:meth: `execute ` will only execute a single SQL statement. If you try to execute
684
- more than one statement with it, it will raise a :exc: `. Warning `. Use
684
+ more than one statement with it, it will raise a :exc: `Warning `. Use
685
685
:meth: `executescript ` if you want to execute multiple SQL statements with one
686
686
call.
687
687
@@ -883,43 +883,74 @@ Now we plug :class:`Row` in::
883
883
Exceptions
884
884
----------
885
885
886
+ The exception hierarchy is defined by the DB-API 2.0 (:pep: `249 `).
887
+
886
888
.. exception :: Warning
887
889
888
- A subclass of :exc: `Exception `.
890
+ This exception is raised by ``sqlite3 `` if an SQL query is not a
891
+ :class: `string <str> `, or if multiple statements are passed to
892
+ :meth: `~Cursor.execute ` or :meth: `~Cursor.executemany `.
893
+ ``Warning `` is a subclass of :exc: `Exception `.
889
894
890
895
.. exception :: Error
891
896
892
- The base class of the other exceptions in this module. It is a subclass
893
- of :exc: `Exception `.
897
+ The base class of the other exceptions in this module.
898
+ Use this to catch all errors with one single :keyword: `except ` statement.
899
+ ``Error `` is a subclass of :exc: `Exception `.
900
+
901
+ .. exception :: InterfaceError
902
+
903
+ This exception is raised by ``sqlite3 `` for fetch across rollback,
904
+ or if ``sqlite3 `` is unable to bind parameters.
905
+ ``InterfaceError `` is a subclass of :exc: `Error `.
894
906
895
907
.. exception :: DatabaseError
896
908
897
909
Exception raised for errors that are related to the database.
910
+ This serves as the base exception for several types of database errors.
911
+ It is only raised implicitly through the specialised subclasses.
912
+ ``DatabaseError `` is a subclass of :exc: `Error `.
913
+
914
+ .. exception :: DataError
915
+
916
+ Exception raised for errors caused by problems with the processed data,
917
+ like numeric values out of range, and strings which are too long.
918
+ ``DataError `` is a subclass of :exc: `DatabaseError `.
919
+
920
+ .. exception :: OperationalError
921
+
922
+ Exception raised for errors that are related to the database's operation,
923
+ and not necessarily under the control of the programmer.
924
+ For example, the database path is not found,
925
+ or a transaction could not be processed.
926
+ ``OperationalError `` is a subclass of :exc: `DatabaseError `.
898
927
899
928
.. exception :: IntegrityError
900
929
901
930
Exception raised when the relational integrity of the database is affected,
902
931
e.g. a foreign key check fails. It is a subclass of :exc: `DatabaseError `.
903
932
904
- .. exception :: ProgrammingError
933
+ .. exception :: InternalError
905
934
906
- Exception raised for programming errors, e.g. table not found or already
907
- exists, syntax error in the SQL statement, wrong number of parameters
908
- specified, etc. It is a subclass of :exc: `DatabaseError `.
935
+ Exception raised when SQLite encounters an internal error.
936
+ If this is raised, it may indicate that there is a problem with the runtime
937
+ SQLite library.
938
+ ``InternalError `` is a subclass of :exc: `DatabaseError `.
909
939
910
- .. exception :: OperationalError
940
+ .. exception :: ProgrammingError
911
941
912
- Exception raised for errors that are related to the database's operation
913
- and not necessarily under the control of the programmer, e.g. an unexpected
914
- disconnect occurs, the data source name is not found, a transaction could
915
- not be processed, etc. It is a subclass of :exc: `DatabaseError `.
942
+ Exception raised for `` sqlite3 `` API programming errors,
943
+ for example trying to operate on a closed :class: ` Connection `,
944
+ or trying to execute non-DML statements with :meth: ` ~Cursor.executemany `.
945
+ `` ProgrammingError `` is a subclass of :exc: `DatabaseError `.
916
946
917
947
.. exception :: NotSupportedError
918
948
919
- Exception raised in case a method or database API was used which is not
920
- supported by the database, e.g. calling the :meth: `~Connection.rollback `
921
- method on a connection that does not support transaction or has
922
- transactions turned off. It is a subclass of :exc: `DatabaseError `.
949
+ Exception raised in case a method or database API is not supported by the
950
+ underlying SQLite library. For example, setting *deterministic * to
951
+ :const: `True ` in :meth: `~Connection.create_function `, if the underlying SQLite library
952
+ does not support deterministic functions.
953
+ ``NotSupportedError `` is a subclass of :exc: `DatabaseError `.
923
954
924
955
925
956
.. _sqlite3-types :
0 commit comments