def setup_players_and_matches(): testDelete() for player in player_list: registerPlayerSample(player[0], player[1], tourn_id=1) tournamentPlayer(player[0], 5) for player in player_list_02: registerPlayerSample(player[0], player[1], tourn_id=13) tournamentPlayer(player[0], 6) createRandomMatches(player_list, 100, tourn_id=1) createRandomMatches(player_list, 100, tourn_id=5) createRandomMatches(player_list_02, 100, tourn_id=13) createRandomMatches(player_list_02, 100, tourn_id=6)
def registerPlayerSample(player_id, name, tourn_id=1): """Add a player to the tournament database. Args: name: the player's full name (need not be unique). """ db, db_cursor = connect() query = "INSERT INTO Player (player_id, name) VALUES (%s, %s)" db_cursor.execute(query, (player_id, name)) db.commit() tournamentPlayer(player_id, tourn_id) db.commit() db.close()