Using a variable in a try,catch,finally statement without declaring it outside

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.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)