Skip to content

Commit 87f0ac8

Browse files
miss-islingtonErlend Egeberg Aasland
and
Erlend Egeberg Aasland
authored
bpo-45089: Improve sqlite3 trace callback docs (GH-28238) (GH-28371)
- 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 <[email protected]>
1 parent 0e4f913 commit 87f0ac8

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
@@ -451,14 +451,22 @@ Connection Objects
451451
Registers *trace_callback* to be called for each SQL statement that is
452452
actually executed by the SQLite backend.
453453

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

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

464+
.. note::
465+
Exceptions raised in the trace callback are not propagated. As a
466+
development and debugging aid, use
467+
:meth:`~sqlite3.enable_callback_tracebacks` to enable printing
468+
tracebacks from exceptions raised in the trace callback.
469+
462470
.. versionadded:: 3.3
463471

464472

0 commit comments

Comments
 (0)