0

I am using exception handling in python-2.7. I am getting exception message like UNIQUE constraint failed: table.name but someone tell me how to get exception error code like 3 /* Access permission denied */?

try:
    cur.execute("INSERT INTO `table` ('name','contact') VALUES(?,?)",
                ('name', 'contact',))
    con.commit()
except Exception as ex:
    print str(ex)
AnamAnam
  • 35
  • 1
  • 6
  • 1
    Possible duplicate of [python: How do I know what type of exception occurred?](https://stackoverflow.com/questions/9823936/python-how-do-i-know-what-type-of-exception-occurred) – galmeriol May 08 '18 at 07:04
  • without printing str(ex) that will never work , because python can't concernate with object or str – Skiller Dz May 08 '18 at 09:15

1 Answers1

0
print (ex.message)

It is good for me.

AJackTi
  • 63
  • 2
  • 7