from sqlmodel import Session, select from database import engine from models import Vertical, Song, Performance with Session(engine) as session: for s in ['dmb', 'dead-and-company']: v = session.exec(select(Vertical).where(Vertical.slug == s)).first() print(f"--- {s} ---") if not v: print("Vertical missing") continue print(f"Vertical ID: {v.id}") perfs = session.exec(select(Performance).join(Song).where(Song.vertical_id == v.id)).all() print(f"Total Perfs: {len(perfs)}") song = session.exec(select(Song).where(Song.title == 'All Along the Watchtower', Song.vertical_id == v.id)).first() if song: watchtower_perfs = session.exec(select(Performance).where(Performance.song_id == song.id)).all() print(f"Watchtower: ID={song.id}, Canon={song.canon_id}, Perfs={len(watchtower_perfs)}") else: print("Watchtower: Missing")