Skip to content Skip to sidebar Skip to footer

Unboundlocalerror: Local Variable 'cur' Referenced Before Assignment

The following code throws the UnboundLocalError: def fetch_results(conn, sql, **bind_params): ''' Immediately fetches the SQL results into memory Trades memory for the

Solution 1:

If conn.cursor() throws an exception, cur will never be assigned, thus the code in the finally block will be referencing cur before assignment.

Try removing that try block and seeing what happens, its likely that conn.cursor() is throwing some kind of exception you'll need to sort out.

Post a Comment for "Unboundlocalerror: Local Variable 'cur' Referenced Before Assignment"