values = (username, )
    cursor.execute(sql, values)
    result = cursor.fetchall()
    if cursor.rowcount == 0:
        return False
    else:
        return True


if __name__ == '__main__':
    # RUN THIS ONCE A DAY TO UPDATE LEADERBOARD?
    cursor = mydb.cursor()
    stock = Stock(mydb, cursor)
    for i in get_usernames_and_money(cursor):
        username = i[0]
        money = float(i[1])
        all_stocks = stock.get_all_stocks_from_user(username)
        total_stock_value = float(stock.get_total_stock_value(all_stocks))
        total_value = money + total_stock_value
        if user_in_leaderboard(cursor, username):
            sql = "UPDATE Leaderboard SET total_value = %s WHERE username = %s"
            values = (total_value, username)
            cursor.execute(sql, values)
        else:
            sql = "INSERT INTO Leaderboard(username, total_value) VALUES (%s, %s)"
            values = (username, total_value)
            cursor.execute(sql, values)
        mydb.commit()

    cursor.close()
    mydb.close()