Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
gh-89018: Improve documentation ofsqlite3 exceptions#27645
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes from18 commits
Commits
Show all changes
19 commits Select commitHold shift + click to select a range
1cee1d0 Document all sqlite3 exceptions
0e6af97 Add markup for except keyword
b3ae237 Address review: adjust DataError wording
defa180 Merge branch 'main' into sqlite-doc-exceptions
86baece WIP
1c20bf5 Merge branch 'main' into sqlite-doc-exceptions
erlend-aasland7951b1c Sync with main
erlend-aasland18d701e Update Doc/library/sqlite3.rst
7a12a7b Update Doc/library/sqlite3.rst
9fec685 Update Doc/library/sqlite3.rst
e0cc0d4 Update Doc/library/sqlite3.rst
1ceb02f Update Doc/library/sqlite3.rst
91494dd Address review
erlend-aaslandaa140d4 Reword ProgrammingError
erlend-aasland59dcdbd Reword Waning
erlend-aasland9c112a8 Revert incorrect change
erlend-aasland8b7293e Revert "Revert incorrect change"
erlend-aaslandc25c95e Update Doc/library/sqlite3.rst
7c1bd6c Adjust a couple of more inconsistencies
erlend-aaslandFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -844,7 +844,7 @@ Cursor Objects | ||
| :ref:`placeholders <sqlite3-placeholders>`. | ||
| :meth:`execute` will only execute a single SQL statement. If you try to execute | ||
| more than one statement with it, it will raise a :exc:`ProgrammingError`. Use | ||
| :meth:`executescript` if you want to execute multiple SQL statements with one | ||
| call. | ||
| @@ -1098,14 +1098,20 @@ Blob Objects | ||
| Exceptions | ||
| ---------- | ||
| The exception hierarchy is defined by the DB-API 2.0 (:pep:`249`). | ||
| .. exception:: Warning | ||
| This exception is not currently raised by the ``sqlite3`` module, | ||
| but may be raised by applications using ``sqlite3``, | ||
| for example if a user-defined function truncates data while inserting. | ||
| ``Warning`` is a subclass of :exc:`Exception`. | ||
| .. exception:: Error | ||
| The base class of the other exceptions in this module. | ||
| Use this to catch all errors with one single :keyword:`except` statement. | ||
| ``Error`` is a subclass of :exc:`Exception`. | ||
| .. attribute:: sqlite_errorcode | ||
| @@ -1121,34 +1127,60 @@ Exceptions | ||
| .. versionadded:: 3.11 | ||
| .. exception:: InterfaceError | ||
| Exception raised for misuse of the low-level SQLite C API. | ||
| In other words, if this exception is raised, it probably indicates a bug in the | ||
| ``sqlite3`` module. | ||
| ``InterfaceError`` is a subclass of :exc:`Error`. | ||
| .. exception:: DatabaseError | ||
| Exception raised for errors that are related to the database. | ||
| This serves as the base exception for several types of database errors. | ||
| It is only raised implicitly through the specialised subclasses. | ||
| ``DatabaseError`` is a subclass of :exc:`Error`. | ||
| .. exception:: DataError | ||
| Exception raised for errors caused by problems with the processed data, | ||
| like numeric values out of range, and strings which are too long. | ||
| ``DataError`` is a subclass of :exc:`DatabaseError`. | ||
| .. exception:: OperationalError | ||
| Exception raised for errors that are related to the database's operation, | ||
| and not necessarily under the control of the programmer. | ||
| For example, the database path is not found, | ||
| or a transaction could not be processed. | ||
| ``OperationalError`` is a subclass of :exc:`DatabaseError`. | ||
erlend-aasland marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| .. exception:: IntegrityError | ||
| Exception raised when the relational integrity of the database is affected, | ||
| e.g. a foreign key check fails. It is a subclass of :exc:`DatabaseError`. | ||
| .. exception::InternalError | ||
| Exception raised when SQLite encounters an internal error. | ||
| If this is raised, it may indicate that there is a problem with the runtime | ||
| SQLite library. | ||
| ``InternalError`` is a subclass of :exc:`DatabaseError`. | ||
| .. exception::ProgrammingError | ||
| Exception raised for``sqlite3`` API programming errors, | ||
| for example supplyingthewrong numberofbindings to a query, | ||
| or trying to operate on a closed :class:`Connection`. | ||
| ``ProgrammingError`` is a subclass of :exc:`DatabaseError`. | ||
| .. exception:: NotSupportedError | ||
| Exception raised in case a method or database API is not supported by the | ||
| underlying SQLite library. For example, setting *deterministic* to | ||
| :const:`True` in :meth:`~Connection.create_function`, if the underlying SQLite library | ||
| does not support deterministic functions. | ||
| ``NotSupportedError`` is a subclass of :exc:`DatabaseError`. | ||
| .. _sqlite3-blob-objects: | ||
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.