The problem was that I chose the wrong exception.
It turned out that the error that occurred actually belongs to the type pymysql.err.IntegrityError, and not sqlalchemy.exc.IntegrityError, as I assumed.
I discovered the type of exception by doing:
import sys try: cursor = connection.cursor() cursor.callproc('my_stored_proc', [arguments]) except: print "Unexpected error:", sys.exc_info()[0]
And I saw this listing:
Unexpected error: <class 'pymysql.err.IntegrityError'>
source share