Re: [sqlalchemy] How to identify unique constraint violation without dependency on a specific database driver?

2020-09-18 Thread Vitaly Krug
Thank you, I was afraid of that.

Best,
Vitaly

On Fri, Sep 18, 2020, 12:08 PM Mike Bayer  wrote

...

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).
>

-- 
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 sqlalchemy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy/CALVBdqt%2BaZ%2BNsf_rjrveWwYNG4AUCV7AfVQysC9A6mFMFcVWfw%40mail.gmail.com.


Re: [sqlalchemy] How to identify unique constraint violation without dependency on a specific database driver?

2020-09-18 Thread Mike Bayer


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 sqlalchemy+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/sqlalchemy/718de06d-97ae-4f73-8614-a4fd0626826fn%40googlegroups.com
>  
> .

-- 
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 sqlalchemy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy/0333a8e1-6545-4621-8a3f-6b85bcadbf68%40www.fastmail.com.


[sqlalchemy] How to identify unique constraint violation without dependency on a specific database driver?

2020-09-18 Thread Vitaly Kruglikov
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. 

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).

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 sqlalchemy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy/718de06d-97ae-4f73-8614-a4fd0626826fn%40googlegroups.com.