acpc-testing-7 / scripts /inspect_db.py
welcometoFightclub's picture
Upload 107 files
bb0f4d5 verified
Raw History Blame Contribute Delete
1.98 kB
"""Quick script to inspect the SQLite database."""
import sqlite3
conn = sqlite3.connect("data/ragdb.sqlite")
cur = conn.cursor()
# Tables
cur.execute("SELECT name FROM sqlite_master WHERE type='table'")
print("Tables:", [r[0] for r in cur.fetchall()])
# Cutoff count
cur.execute("SELECT COUNT(*) FROM cutoffs")
print("Cutoff rows:", cur.fetchone()[0])
# Columns
cur.execute("PRAGMA table_info(cutoffs)")
print("Columns:", [(r[1], r[2]) for r in cur.fetchall()])
# Top 10 by lowest open_hs (best/most competitive)
cur.execute(
"SELECT institute_name, course, city, open_hs "
"FROM cutoffs WHERE open_hs IS NOT NULL ORDER BY open_hs ASC LIMIT 10"
)
print("\nTop 10 by LOWEST open_hs (most competitive):")
for r in cur.fetchall():
print(f" {r}")
# Top 10 by highest open_hs (least competitive)
cur.execute(
"SELECT institute_name, course, city, open_hs "
"FROM cutoffs WHERE open_hs IS NOT NULL ORDER BY open_hs DESC LIMIT 10"
)
print("\nTop 10 by HIGHEST open_hs (least competitive):")
for r in cur.fetchall():
print(f" {r}")
# Sample of distinct institute types
cur.execute("SELECT DISTINCT institute_type FROM cutoffs")
print("\nInstitute types:", [r[0] for r in cur.fetchall()])
# Sample of distinct courses
cur.execute("SELECT DISTINCT course FROM cutoffs LIMIT 20")
print("\nCourses (first 20):", [r[0] for r in cur.fetchall()])
# Check DAIICT, Nirma, LDCE presence
cur.execute(
"SELECT institute_name, course, open_hs FROM cutoffs "
"WHERE institute_name LIKE '%DAIICT%' OR institute_name LIKE '%Nirma%' "
"OR institute_name LIKE '%L.D.%' OR institute_name LIKE '%LD %' LIMIT 10"
)
print("\nDAIICT/Nirma/LD rows:")
for r in cur.fetchall():
print(f" {r}")
# Check what null ratios look like
cur.execute("SELECT COUNT(*) FROM cutoffs WHERE open_hs IS NULL")
null_count = cur.fetchone()[0]
cur.execute("SELECT COUNT(*) FROM cutoffs")
total = cur.fetchone()[0]
print(f"\nNull open_hs: {null_count}/{total}")
conn.close()