File size: 494 Bytes
db7ef8e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | import duckdb
c = duckdb.connect(r"C:\Users\sayan\Downloads\FinAi\data\mbf.duckdb", read_only=True)
rows = c.execute(
"SELECT table_name, table_type FROM information_schema.tables "
"WHERE table_schema='main' ORDER BY 1"
).fetchall()
print(f"TABLES ({len(rows)}):")
for r in rows:
try:
n = c.execute(f'SELECT COUNT(*) FROM "{r[0]}"').fetchone()[0]
except Exception as e: # noqa: BLE001
n = f"ERR {e}"
print(f" {r[0]:<35} {r[1]:<10} rows={n}")
|