Name Error on MySQLDb
Question: I am working on this Python Credits on your account system, but it appears my
last for loop isn't running leading to a time_set not being defined. Does
anybody know why my last for loop isn't running. Database details have been
removed for security reasons. Here is my code:

    
    
    from time import sleep
    import MySQLdb
    db = MySQLdb.connect(host="", # your host, usually localhost
                         user="", # your username
                          passwd="", # your password
                          db="") # name of the data base
    cursor = db.cursor()#Defines a cursor allowing me to execute SQL commands
    def timer(time, _print=False):
        if time == 0:
            cursor.execute("SELECT * FROM Accounts WHERE Username='{0}';".format(name))
            cursor.execute("UPDATE Accounts SET Credits = 0 WHERE Username = '{1}';".format(creds, name))
            return ''
        else:
            if _print: print time
            sleep(1)
            return timer(time - 1, _print)
    name = raw_input("What username would you like to add credits to?:")
    cursor.execute("SELECT * FROM Accounts WHERE Username='{0}';".format(name))
    creds = input("How many credits would you like to add to the account?")
    for test in cursor.fetchall():
        creds = creds + test[3]
    cursor.execute("UPDATE Accounts SET Credits = {0} WHERE Username = '{1}';".format(creds, name))
    for row in cursor.fetchall():
        time_set = creds * 60
        print time_set
    timer(time_set, True)
    


Answer: It appears that you are trying to pull rows from an UPDATE query, which will
get you nowhere since UPDATE does not return any rows.

