Re: [sqlalchemy] event updating sibling objects: commit() vs. flush()

2021-02-05 Thread Mike Bayer
On Fri, Feb 5, 2021, at 6:37 PM, Gord Thompson wrote: > Hi all. While trying to get more fluent with ORM I looked into a solution for > this Stack Overflow question . > For a many-to-one relationship only one child object can have > `is_default=Tru

[sqlalchemy] event updating sibling objects: commit() vs. flush()

2021-02-05 Thread Gord Thompson
Hi all. While trying to get more fluent with ORM I looked into a solution for this Stack Overflow question . For a many-to-one relationship only one child object can have `is_default=True`. If we add a new child object or update an existing one with

Re: [sqlalchemy] Re: Conditional insert in one transaction

2021-02-05 Thread Mike Bayer
SQLAlchemy will wrap that psycopg2 exception underneath IntegrityError (or at least DBAPIError at the bottommost) so you need to catch the SQLAlchemy-specific expression. of course you should also test it with an existing row to make sure it actually catches and works! On Thu, Feb 4, 2021,