Files
Omika/tools/diag_interventions.py
2026-10-23 18:46:50 +02:00

35 lines
1.0 KiB
Python

import sqlite3, json
db = r'C:\Users\Susana\AppData\Local\Omika\omika.db'
con = sqlite3.connect(db)
cur = con.cursor()
tables = ['Intervention', 'InterventionCache', 'ContextInterventionCache', 'DossierInterventionCache']
for t in tables:
try:
n = cur.execute('SELECT COUNT(*) FROM "%s"' % t).fetchone()[0]
print('%s: %d' % (t, n))
except Exception as e:
print('%s: ERR %s' % (t, e))
print()
# Colonnes des tables intervention
for t in ['Intervention', 'InterventionCache']:
try:
cols = [r[1] for r in cur.execute('PRAGMA table_info("%s")' % t).fetchall()]
print('%s columns: %s' % (t, cols))
except Exception as e:
print('%s cols ERR %s' % (t, e))
print()
# Un exemple d'intervention si présent
for t in ['Intervention', 'InterventionCache', 'ContextInterventionCache']:
try:
rows = cur.execute('SELECT * FROM "%s" LIMIT 1' % t).fetchall()
if rows:
print('%s sample: %s' % (t, str(rows[0])[:600]))
except Exception as e:
pass
con.close()