with closing(getConnection(database)) as connection:
    with closing(connection.cursor()) as cursor:
        cursor.execute('some query')
Using a variable in a try,catch,finally statement without declaring it outside