Ejemplo n.º 1
0
def write_player_attributes(player, player_attributes, date=util.get_today_date()+" 00:00:00"):
    """
    Write a new player attribute in the DB
    :param player:
    :param player_attributes:
    :param date:
    :return:
    """
    log.debug("write_player_attributes of player_fifa_api_id = [" + str(player.player_fifa_api_id) + "]")

    player_attributes["player_fifa_api_id"] = player.player_fifa_api_id
    player_attributes["player_api_id"] = player.player_api_id
    player_attributes["date"] = date

    SQLLite.get_connection().insert("Player_Attributes", player_attributes)
    Cache.del_element(player.player_fifa_api_id, "PLAYER_ATTRIBUTES")
def write_team_attributes(team,
                          team_attributes,
                          date=util.get_today_date() + " 00:00:00"):
    """
    Persist the team attributes of the team
    :param team:
    :param team_attributes:
    :param date:
    :return:
    """
    log.debug("write_team_attributes of team_fifa_api_id = [" +
              str(team.team_fifa_api_id) + "]")

    team_attributes["team_fifa_api_id"] = team.team_fifa_api_id
    team_attributes["team_api_id"] = team.team_api_id
    team_attributes["date"] = date

    SQLLite.get_connection().insert("Team_Attributes", team_attributes)
    Cache.del_element(team.team_fifa_api_id, "TEAM_ATTRIBUTES")
Ejemplo n.º 3
0
def update(player):
    """
    Update the player in the DB, and return the last version of it
    :param player:
    :return:
    """
    SQLLite.get_connection().update("Player", player)

    Cache.del_element(player.player_fifa_api_id, "PLAYER_BY_FIFA_API_ID")
    Cache.del_element(player.player_api_id, "PLAYER_BY_API_ID")
    Cache.del_element(player.player_name, "PLAYER_BY_NAME")
    Cache.del_element(player.id, "PLAYER_BY_ID")

    return read_by_id(player.id)