import sqlite3
c=sqlite3.connect("/home/ultimo/.n8n/database.sqlite")
def q(sql,p=()): return c.execute(sql,p).fetchall()
print("=== dispatcher: últimas 10 execuções ===")
for r in q("SELECT substr(startedAt,12,8),status FROM execution_entity WHERE workflowId=? ORDER BY id DESC LIMIT 10",("qBWf8H9yx6JkR1or",)):
    print("  ",r[0],r[1])
print("=== contagem dispatcher (todas registradas) ===")
for r in q("SELECT status,count(*) FROM execution_entity WHERE workflowId=? GROUP BY status",("qBWf8H9yx6JkR1or",)):
    print("  ",r[0],r[1])
print("=== beatriz-v2-inbound: últimas 5 ===")
for r in q("SELECT substr(startedAt,12,8),status FROM execution_entity WHERE workflowId=? ORDER BY id DESC LIMIT 5",("bzv290ff090ffefe",)):
    print("  ",r[0],r[1])
