Documentation for tracer mechanism

This commit is contained in:
Simon Willison 2020-09-07 14:54:07 -07:00
commit f12251092c
12 changed files with 68 additions and 22 deletions

View file

@ -771,7 +771,7 @@ def query(
for ext in load_extension:
db.conn.load_extension(ext)
with db.conn:
cursor = db.conn.execute(sql, dict(param))
cursor = db.execute(sql, dict(param))
if cursor.description is None:
# This was an update/insert
headers = ["rows_affected"]

View file

@ -124,9 +124,9 @@ class Database:
else:
assert not recreate, "recreate cannot be used with connections, only paths"
self.conn = filename_or_conn
if recursive_triggers:
self.conn.execute("PRAGMA recursive_triggers=on;")
self._tracer = tracer
if recursive_triggers:
self.execute("PRAGMA recursive_triggers=on;")
@contextlib.contextmanager
def tracer(self, tracer=None):
@ -940,7 +940,7 @@ class Table(Queryable):
table=fts_table
)
)
self.db.conn.execute(
self.db.execute(
textwrap.dedent(
"""
DELETE FROM [{table}_docsize] WHERE {column} NOT IN (