def get_bat_stats_for_lineup_spot_by_player_for_team( cls, db_engine, bat_order_list, team_id_bbref, year): s = select([cls]).where( and_(cls.bat_order.in_(bat_order_list), cls.team_id_bbref == team_id_bbref, cls.year == year)) results = db_engine.execute(s).fetchall() return BatStatsMetrics.from_query_results(results) if results else []
def get_bat_stats_for_starters_for_team(cls, db_engine, team_id_bbref, year): s = select([cls]).where( and_(cls.team_id_bbref == team_id_bbref, cls.year == year)) results = db_engine.execute(s).fetchall() return BatStatsMetrics.from_query_results( results)[0] if results else None
def get_bat_stats_for_defpos_by_year_for_team(cls, db_engine, def_position_list, team_id_bbref): s = select([cls]).where( and_(cls.def_position.in_(def_position_list), cls.team_id_bbref == team_id_bbref)) results = db_engine.execute(s).fetchall() return BatStatsMetrics.from_query_results(results) if results else []
def get_bat_stats_for_season_for_all_teams(cls, db_engine, year): s = select([cls]).where(cls.year == year) results = db_engine.execute(s).fetchall() return BatStatsMetrics.from_query_results(results) if results else []
def get_bat_stats_by_year_for_team(cls, db_engine, team_id_bbref): s = select([cls]).where(cls.team_id_bbref == team_id_bbref) results = db_engine.execute(s).fetchall() return BatStatsMetrics.from_query_results(results) if results else []
def get_bat_stats_for_defpos_for_season_for_all_teams( cls, db_engine, def_position_list, year): s = select([cls]).where( and_(cls.def_position.in_(def_position_list), cls.year == year)) results = db_engine.execute(s).fetchall() return BatStatsMetrics.from_query_results(results) if results else []
def get_bat_stats_for_lineup_spot_for_season_for_all_teams( cls, db_engine, bat_order_list, year): s = select([cls]).where( and_(cls.bat_order.in_(bat_order_list), cls.year == year)) results = db_engine.execute(s).fetchall() return BatStatsMetrics.from_query_results(results) if results else []
def get_bat_stats_for_career_for_player(cls, db_engine, mlb_id): s = select([cls]).where(cls.mlb_id == mlb_id) results = db_engine.execute(s).fetchall() return BatStatsMetrics.from_query_results( results)[0] if results else None