Files
mtusi2026lab5/scripts/query_pipeline.py
T

15 lines
654 B
Python

import json
import sys
from pathlib import Path
sys.path.insert(0,str(Path(__file__).resolve().parents[1]))
from app import store
from psycopg.rows import dict_row
store.pool.open(wait=True,timeout=20)
try:
with store.connect() as conn:
rows=conn.cursor(row_factory=dict_row).execute('''SELECT j.id AS job_id,j.state,j.attempt,j.lease_until,
a.pipeline_version,o.published_at,o.deliveries FROM jobs j JOIN attachments a ON a.id=j.attachment_id
JOIN outbox o ON o.job_id=j.id WHERE a.id=%s ORDER BY j.pipeline_version''',(sys.argv[1],)).fetchall()
print(json.dumps(rows,default=str))
finally:store.pool.close()