Skip to content

Commit 51056b4

Browse files
author
Erlend Egeberg Aasland
authored
bpo-45089: Improve sqlite3 trace callback docs (GH-28238)
- Add link to str object and sqlite3 transaction control - Mention that exceptions are not propagated
1 parent ff6d2cc commit 51056b4

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

Doc/library/sqlite3.rst

+13-5
Original file line numberDiff line numberDiff line change
@@ -460,14 +460,22 @@ Connection Objects
460460
Registers *trace_callback* to be called for each SQL statement that is
461461
actually executed by the SQLite backend.
462462

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

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

473+
.. note::
474+
Exceptions raised in the trace callback are not propagated. As a
475+
development and debugging aid, use
476+
:meth:`~sqlite3.enable_callback_tracebacks` to enable printing
477+
tracebacks from exceptions raised in the trace callback.
478+
471479
.. versionadded:: 3.3
472480

473481

0 commit comments

Comments
 (0)