kin: auto-commit after pipeline
This commit is contained in:
parent
94591ab7ae
commit
3d9b5766ab
10 changed files with 250 additions and 30 deletions
|
|
@ -572,14 +572,26 @@ def write_log(
|
|||
message: str,
|
||||
level: str = "INFO",
|
||||
extra: dict | list | None = None,
|
||||
ts: str | None = None,
|
||||
) -> dict:
|
||||
"""Insert a pipeline log entry. Returns inserted row as dict."""
|
||||
"""Insert a pipeline log entry. Returns inserted row as dict.
|
||||
|
||||
ts: optional ISO-8601 UTC timestamp override (e.g. for retrospective PM entries).
|
||||
If None, the DB DEFAULT (datetime('now')) is used.
|
||||
"""
|
||||
extra_json = json.dumps(extra, ensure_ascii=False) if extra is not None else None
|
||||
cur = conn.execute(
|
||||
"""INSERT INTO pipeline_log (pipeline_id, message, level, extra_json)
|
||||
VALUES (?, ?, ?, ?)""",
|
||||
(pipeline_id, message, level, extra_json),
|
||||
)
|
||||
if ts is not None:
|
||||
cur = conn.execute(
|
||||
"""INSERT INTO pipeline_log (pipeline_id, ts, message, level, extra_json)
|
||||
VALUES (?, ?, ?, ?, ?)""",
|
||||
(pipeline_id, ts, message, level, extra_json),
|
||||
)
|
||||
else:
|
||||
cur = conn.execute(
|
||||
"""INSERT INTO pipeline_log (pipeline_id, message, level, extra_json)
|
||||
VALUES (?, ?, ?, ?)""",
|
||||
(pipeline_id, message, level, extra_json),
|
||||
)
|
||||
conn.commit()
|
||||
row = conn.execute(
|
||||
"SELECT * FROM pipeline_log WHERE id = ?", (cur.lastrowid,)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue