def create_sport(self, data): try: with self._database_engine.new_session() as session: # Save sport in database sport = SportDAO(session).create(data) sport_data = sport.to_dict() return sport_data except Error as e: # log error raise e
def get_sport(self, sport_id): with self._database_engine.new_session() as session: sport = SportDAO(session).get(sport_id) sport_data = sport.to_dict() return sport_data
def get_sport_by_name(self, name: str): with self._database_engine.new_session() as session: sport = SportDAO(session).get_by_name(name) sport_data = sport.to_dict() return sport_data
def get_sport(self, sport_id): logging.info("Get sport %s" % sport_id) with self._database_engine.new_session() as session: sport = SportDAO(session).get(sport_id) sport_data = sport.to_dict() return sport_data