#!/bin/bash
export LC_ALL=C
python3 - <<'PY'
import sqlite3, json
c=sqlite3.connect('/root/.9router/db/data.sqlite'); c.row_factory=sqlite3.Row
cols=[r[1] for r in c.execute("pragma table_info(requestDetails)")]
print("cols:", cols)
rows=c.execute("select * from requestDetails order by timestamp desc limit 6").fetchall()
for r in rows:
    d=dict(r)
    print(f"\n--- {d.get('timestamp')} provider={d.get('provider')} model={d.get('model')} status={d.get('status')}")
    data=d.get('data')
    if data:
        try:
            j=json.loads(data)
            for k,v in j.items():
                s=json.dumps(v, ensure_ascii=False) if not isinstance(v,str) else v
                print(f"    {k}: {s[:500]}")
        except Exception:
            print("    raw:", str(data)[:600])
PY
