python exception message capturing

You have to define which type of exception you want to catch. So write except Exception, e: instead of except, e: for a general exception (that will be logged anyway). Other possibility is to write your whole try/except code this way: in Python 3.x and modern versions of Python 2.x use except Exception as e instead of except Exception, e:

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