SQLAlchemy does not catch postgresql.exceptions.UniqueError
Issue #3421
resolved
SQLAlchemy does not catch postgresql.exceptions.UniqueError. In normal case SQLAlchemy catches all exceptions and make standardized exceptions.
This exception should be an sqlalchemy.exc.IntegrityError.
Comments (4)
-
repo owner -
repo owner -
repo owner - changed status to resolved
- Added support for the case of the misbehaving DBAPI that has
pep-249 exception names linked to exception classes of an entirely
different name, preventing SQLAlchemy's own exception wrapping from
wrapping the error appropriately.
The SQLAlchemy dialect in use needs to implement a new
accessor :attr:
.DefaultDialect.dbapi_exception_translation_map
to support this feature; this is implemented now for the py-postgresql dialect. fixes#3421
→ <<cset d178707ecaeb>>
-
reporter Thank you!
- Log in to comment
the reason this occurs is because py-postgresql is using a hack for their IntegrityError, by re-using an entirely different exception class with a different name:
we'd have to rewrite our entire exception wrapping system to support this. py-postgresql hasn't had a release in three years and is a dead project; the psycopg2 project supports Python 3 and is an industry-wide standard for Python postgresql access. Can't you just use that ?