Files
MoFin/scripts/list_tables.py
T

8 lines
310 B
Python

import sqlite3
db = sqlite3.connect('/home/hmo/web-dashboard/data/mofin.db')
tables = [r[0] for r in db.execute("SELECT name FROM sqlite_master WHERE type='table' ORDER BY name")]
for t in tables:
cols = [r[1] for r in db.execute(f"PRAGMA table_info({t})")]
print(f"{t}: {', '.join(cols)}")
db.close()