Exemplo n.º 1
0
    def get_ven_range(cls, ta_name):
        if not ta_name or ta_name is None:
            raise ValueError(cls.EX_TA_NAME.format(ta_name))

        con = None
        cursor = None
        try:
            con = DBResource.get_instance().get_connection()
            cursor = con.cursor()
            cursor.execute(cls.GET_VEN_RANGE, (ta_name, ))
            if cursor is not None:
                inn_range = cursor.fetchmany(5)
                bat_avg_range = cursor.fetchmany(5)
                bat_sr_range = cursor.fetchmany(5)
                centuries_range = cursor.fetchmany(2)
                fifties_range = cursor.fetchmany(2)
                hs_range = cursor.fetchmany(5)
                overs_range = cursor.fetchmany(5)
                bowl_avg_range = cursor.fetchmany(5)
                bowl_sr_range = cursor.fetchmany(5)
                ff_range = cursor.fetchmany(2)
                return [
                    inn_range, bat_avg_range, bat_sr_range, centuries_range,
                    fifties_range, hs_range, overs_range, bowl_avg_range,
                    bowl_sr_range, ff_range
                ]
        except BaseException as be:
            raise RuntimeError(cls.EX_VEN_RANGE.format(ta_name), be)
        finally:
            cursor.close()
            con.close()
Exemplo n.º 2
0
 def get_grounds(cls):
     grounds = []
     con = None
     cursor = None
     try:
         con = DBResource.get_instance().get_connection()
         cursor = con.cursor()
         cursor.execute(cls.GET_GROUNDS)
         for row in cursor:
             grounds.append(row[0])
         return grounds
     except BaseException as be:
         raise RuntimeError(cls.EX_GROUNDS, be)
     finally:
         cursor.close()
         con.close()
Exemplo n.º 3
0
    def get_player_role(cls, player_name):
        if not player_name or player_name is None:
            raise ValueError(cls.EX_INVALID_PLAYER_NAME.format(player_name))

        con = None
        cursor = None
        try:
            con = DBResource.get_instance().get_connection()
            cursor = con.cursor()
            cursor.execute(cls.GET_PLAYER_ROLE % player_name)
            for row in cursor:
                return row[0]
        except BaseException as be:
            raise RuntimeError(cls.EX_PLAYER_ROLE.format(player_name), be)
        finally:
            cursor.close()
            con.close()
Exemplo n.º 4
0
 def get_teams(cls):
     teams = []
     con = None
     cursor = None
     try:
         con = DBResource.get_instance().get_connection()
         cursor = con.cursor()
         # rs = cursor.execute(cls.GET_TEAMS)
         cursor.execute(cls.GET_TEAMS)
         for row in cursor:
             teams.append(row[0])
         return teams
     except BaseException as be:
         raise RuntimeError(cls.EX_TEAMS, be)
     finally:
         cursor.close()
         con.close()
Exemplo n.º 5
0
    def get_team_id(cls, team_name):
        if not team_name or team_name is None:
            raise ValueError(cls.EX_TEAM_NAME.format(team_name))

        con = None
        cursor = None
        try:
            con = DBResource.get_instance().get_connection()
            cursor = con.cursor()
            cursor.execute(cls.GET_TEAM_ID, (team_name, ))
            for row in cursor:
                return row[0]
        except BaseException as be:
            raise RuntimeError(cls.EX_TEAM_ID.format(team_name), be)
        finally:
            cursor.close()
            con.close()
Exemplo n.º 6
0
    def get_players(cls, team_name):
        if not team_name or team_name is None:
            raise ValueError(cls.EX_INVALID_TEAM_NAME.format(team_name))

        players = []
        con = None
        cursor = None
        try:
            con = DBResource.get_instance().get_connection()
            cursor = con.cursor()
            cursor.execute(cls.GET_PLAYERS, (team_name, ))
            for row in cursor:
                players.append(row[0])
            return players
        except BaseException as be:
            raise RuntimeError(cls.EX_PLAYERS.format(team_name), be)
        finally:
            cursor.close()
            con.close()
Exemplo n.º 7
0
    def get_player_id(cls, players_list):
        if not players_list or players_list is None:
            raise ValueError(cls.EX_INVALID_PLAYERS.format(players_list))

        p_list = []
        con = None
        cursor = None
        try:
            con = DBResource.get_instance().get_connection()
            cursor = con.cursor()
            cursor.execute(cls.GET_PLAYER_ID, (players_list, ))
            for row in cursor:
                p_list.append(row[0])
            return p_list
        except BaseException as be:
            raise RuntimeError(cls.EX_PLAYER_ID.format(players_list), be)
        finally:
            cursor.close()
            con.close()