def registerPlayer(name): """Adds a player to the tournament database. Args: name: the player's full name (need not be unique). """ cursor = DB().cursor() # Get already escaped SQL statement query = cursor.mogrify("INSERT INTO players (name) VALUES (%s)", (name,)) DB().execute(query, True)
def reportMatch(winner, loser): """Records the outcome of a single match between two players. Args: winner: the id number of the player who won loser: the id number of the player who lost """ cursor = DB().cursor() query = cursor.mogrify( "INSERT INTO matches (winner, loser) VALUES (%s, %s)", (winner, loser)) DB().execute(query, True)