0

I need help figuring out how to fix my code. Every time I run the code its traceback is to this part of it. My code is Unbound Local Error for 'result'.

Please see code below:

def Level1(self):
        sql = "SELECT easyhint, gps, qrcode FROM gamedb WHERE quad = 1 ORDER BY RANDOM () LIMIT 1;"

        try:
            cursor.execute(sql)
            result = cursor.fetchmany(size = 7)
        except Exception, e:
            print e

        for row in result:
            while 'easyhint' < 8:
                if 'gps' in row and 'number' in self.person:
                    return row.easyhint.itervalues()
                else:
                    return 0

Any help or suggestions are welcomed.

Any help or suggestions are welcomed.

2
Contributors
1
Reply
5
Views
4 Years
Discussion Span
Last Post by scaba
0

Declare 'result' outside of the try/except block:

result = []
try:
    cursor.execute(sql)
    result = cursor.fetchmany(size = 7)
except Exception, e:
    print e
for row in result:
    etc...
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.