from typing import List import pandas as pd from config.models import Call, Participant from setup import db_engine, session def get_call_data(usernames: List) -> pd.DataFrame: query_calls = ( session.query(Call, Participant.username) .filter(Participant.id == Call.participant_id) .filter(Participant.username.in_(usernames)) ) with db_engine.connect() as connection: df_calls = pd.read_sql(query_calls.statement, connection) return df_calls