On Fri, Sep 18, 2020, at 3:34 PM, Vitaly Kruglikov wrote: > My table has a unique index on the column named "tag". When I attempt to > insert a row with a tag value that already exists in the table, sqlalchemy > raises the generic exception `IntegrityError`. > > `IntegrityError` may be raised for various scenarios, including Foreign Key > Violation and Unique Index Violation. > > One of the benefits of using sqlalchemy is the ability to write code that may > be independent of the underlying backend or db-api driver.
this is true for the most part! unfortunately, not in this very specific part :( > > So, I am hoping that there is a programmatic way to distinguish between the > underlying causes of IntegrityError (such as unique constraint violation) > without having to depend explicitly on a specific driver package (e.g., > psycopg2). you have you set up a catch that will apply regular expressions to match the error conditions you want. there's no platform agnostic registry maintained of these right now (it would be massive). > > Thank you, > Vitaly > > -- > SQLAlchemy - > The Python SQL Toolkit and Object Relational Mapper > > http://www.sqlalchemy.org/ > > To post example code, please provide an MCVE: Minimal, Complete, and > Verifiable Example. See http://stackoverflow.com/help/mcve for a full > description. > --- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/sqlalchemy/718de06d-97ae-4f73-8614-a4fd0626826fn%40googlegroups.com > > <https://groups.google.com/d/msgid/sqlalchemy/718de06d-97ae-4f73-8614-a4fd0626826fn%40googlegroups.com?utm_medium=email&utm_source=footer>. -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description. --- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/sqlalchemy/0333a8e1-6545-4621-8a3f-6b85bcadbf68%40www.fastmail.com.
