Python does not have block scope. Anything defined inside the try block will be available outside.
That said, you would still have a problem: if it is the getConnection() call that raises the error, cursor will be undefined, so the reference in the finally block will error.