Tracer example using print, refs #150

This commit is contained in:
Simon Willison 2020-09-08 16:27:55 -07:00
commit 32f1badfec

View file

@ -67,10 +67,10 @@ You can also turn on a tracer function temporarily for a block of code using the
db = Database(memory=True) db = Database(memory=True)
# ... later # ... later
with db.tracer(tracer): with db.tracer(print):
db["dogs"].insert({"name": "Cleo"}) db["dogs"].insert({"name": "Cleo"})
Queries will be passed to your ``tracer()`` function only for the duration of the ``with`` block. This example will print queries only for the duration of the ``with`` block.
.. _python_api_execute: .. _python_api_execute: