Download apps/api/_inspect_db.py from Sandy-sys/finai: direct link, hf CLI and curl.
- Browser
- Download file 494 Bytes
-
https://huggingface.co/spaces/Sandy-sys/finai/resolve/main/apps/api/_inspect_db.py
- Command line
-
hf download hf://spaces/Sandy-sys/finai/apps/api/_inspect_db.py
-
curl -L -o _inspect_db.py https://huggingface.co/spaces/Sandy-sys/finai/resolve/main/apps/api/_inspect_db.py
494 Bytes
| 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}") | |