Skip to content

Commit 97802a8

Browse files
miss-islingtonErlend Egeberg Aasland
and
Erlend Egeberg Aasland
authored
bpo-45089: Improve sqlite3 trace callback docs (GH-28238) (GH-28372)
- 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 4ce55cc commit 97802a8

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

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

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

459+
.. note::
460+
Exceptions raised in the trace callback are not propagated. As a
461+
development and debugging aid, use
462+
:meth:`~sqlite3.enable_callback_tracebacks` to enable printing
463+
tracebacks from exceptions raised in the trace callback.
464+
457465
.. versionadded:: 3.3
458466

459467

0 commit comments

Comments
 (0)