Skip to content

Commit

Permalink
bpo-45089: Improve sqlite3 trace callback docs (GH-28238) (GH-28371)
Browse files Browse the repository at this point in the history
- Add link to str object and sqlite3 transaction control
- Mention that exceptions are not propagated
(cherry picked from commit 51056b4)

Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>
  • Loading branch information
miss-islington and Erlend Egeberg Aasland authored Sep 15, 2021
1 parent 0e4f913 commit 87f0ac8
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions Doc/library/sqlite3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -451,14 +451,22 @@ Connection Objects
Registers *trace_callback* to be called for each SQL statement that is
actually executed by the SQLite backend.

The only argument passed to the callback is the statement (as string) that
is being executed. The return value of the callback is ignored. Note that
the backend does not only run statements passed to the :meth:`Cursor.execute`
methods. Other sources include the transaction management of the Python
module and the execution of triggers defined in the current database.
The only argument passed to the callback is the statement (as
:class:`str`) that is being executed. The return value of the callback is
ignored. Note that the backend does not only run statements passed to the
:meth:`Cursor.execute` methods. Other sources include the
:ref:`transaction management <sqlite3-controlling-transactions>` of the
sqlite3 module and the execution of triggers defined in the current
database.

Passing :const:`None` as *trace_callback* will disable the trace callback.

.. note::
Exceptions raised in the trace callback are not propagated. As a
development and debugging aid, use
:meth:`~sqlite3.enable_callback_tracebacks` to enable printing
tracebacks from exceptions raised in the trace callback.

.. versionadded:: 3.3


Expand Down

0 comments on commit 87f0ac8

Please sign in to comment.