import sqlite3 for label, path in [('canonical', '/home/hmo/MoFin/data/mofin.db'), ('profile-local', '/home/hmo/.hermes/profiles/position-analyst/scripts/data/mofin.db'), ('web-dashboard', '/home/hmo/web-dashboard/data/mofin.db')]: try: c = sqlite3.connect(path, timeout=5) tables = [r[0] for r in c.execute("SELECT name FROM sqlite_master WHERE type='table'")] print(f'=== {label}: {path}') for t in ['price_events', 'holdings', 'live_prices', 'holding_strategies', 'market_snapshots']: if t in tables: cnt = c.execute(f"SELECT COUNT(*) FROM {t}").fetchone()[0] try: col = 'created_at' if t in ('price_events', 'market_snapshots') else 'updated_at' last = c.execute(f"SELECT MAX({col}) FROM {t}").fetchone()[0] except Exception: last = '?' print(f' {t}: {cnt} rows, last={last}') else: print(f' {t}: MISSING') c.close() except Exception as e: print(f'{label}: ERROR {e}') print()