TIF_E41253310/scripts/checks/check_current_db_data.py

16 lines
587 B
Python

import sys
sys.path.append('Backend')
from app.config.database import engine
from sqlalchemy import text
with engine.connect() as conn:
for tbl in ['alumni', 'pekerjaan', 'kompetensi', 'tracer_responses']:
cnt = conn.execute(text(f"SELECT COUNT(*) FROM {tbl};")).scalar()
print(f"Table {tbl}: {cnt} rows")
# Check per year in alumni
res = conn.execute(text("SELECT tahun_lulus, COUNT(*) FROM alumni GROUP BY tahun_lulus ORDER BY tahun_lulus;")).fetchall()
print("\nAlumni per tahun_lulus:")
for r in res:
print(f" {r[0]}: {r[1]} rows")