TIF_E41253310/scripts/checks/check_db_2019.py

14 lines
616 B
Python

import sys
sys.path.append('Backend')
from app.config.database import engine
from sqlalchemy import text
with engine.connect() as conn:
cnt = conn.execute(text("SELECT COUNT(*) FROM alumni;")).scalar()
print(f"Total alumni in DB: {cnt}")
if cnt and cnt > 0:
rows = conn.execute(text("SELECT alumni.nim, alumni.tahun_lulus, tr.cari_iklan, tr.cari_melamar_tanpa_lowongan, tr.kerja_tidak_sesuai_1, tr.kerja_tidak_sesuai_2 FROM alumni JOIN tracer_responses tr ON alumni.id = tr.alumni_id LIMIT 15;")).fetchall()
print("\nSample rows in DB:")
for r in rows:
print(" ", r)