I skipped the following code,
import pyodbc try: pyodbc.connect('DRIVER={%s};SERVER=%s;DATABASE=%s;UID=%s;PWD=%s' % (driver, server, database, uid, password)) except pyodbc.Error, err: logging.warn(err)
Error message format i get is
('HY000', "[HY000] [MySQL][ODBC 5.1 Driver]Access denied for user 'root'@'192.168.2.27' (using password: YES) (1045) (SQLDriverConnect)")
I want to receive only a part of the error message i.e.
Access denied for user 'root'@'192.168.2.27'(using password: YES)
I do not know if I can catch errors, for example, the driver was not found, the host, etc.
I also tried to catch errors like:
except pyodbc.OperationalError, err: logging.warn(err) except pyodbc.DataError, err: logging.warn(err) except pyodbc.IntegrityError, err: logging.warn(err) except pyodbc.ProgrammingError, err: logging.warn(err) except pyodbc.NotSupportedError, err: logging.warn(err) except pyodbc.DatabaseError, err: logging.warn(err) except pyodbc.Error, err: logging.warn(err)
but the latter always detects an error.
Fruthermore, I saw that pyodbc.Error.message is always empty. How can I get only an error message.
thanks