how to catch specific pyodbc error message
This worked for me. try: cnxn = pyodbc.connect(…) except pyodbc.Error as ex: sqlstate = ex.args[0] if sqlstate == ‘28000’: print(“LDAP Connection failed: check password”) There are different SQLSTATES and you can have if-else statements to print out the cause. Similarly, try: cnxn = pyodbc.connect(…) except pyodbc.Error as ex: sqlstate = ex.args[1] print(sqlstate) will give you … Read more