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

2021-02-04 Thread Vitaly Kruglikov
Additional background: In the proposed code snippet, I placed the try/except around the `begin_nested()` block instead of just the `orm_session.add()` statement because the `add()` might not get flushed to database until the savepoint is released in the event the session is not auto-flushing.

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

2021-02-04 Thread Vitaly Kruglikov
Thanks Mike! I followed up on your suggestion concerning savepoints and came up with the following code snippet. Does this look right to you? ``` try: with orm_session.begin_nested(): orm_session.add(record) except psycopg2.errors.UniqueViolation as error: # or is it

Re: [sqlalchemy] Parameterized "Relationships" with Eager Loading Capability

2021-02-04 Thread Mike Bayer
it's not simple to work with a criteria object since you would have to walk through it to make some programmatic decision about it, and you'd also have to search for it.I can't completely guarantee this wont change so it would be better if you solved your problem differently, but here's how

Re: [sqlalchemy] Parameterized "Relationships" with Eager Loading Capability

2021-02-04 Thread agrot...@gmail.com
In the case of using the PropComparator.and_() operator (https://docs.sqlalchemy.org/en/14/orm/loading_relationships.html#adding-criteria-to-loader-options), is there any way to then introspect the relationship to tell what if any and_ filtering has been applied to the load? For example on a,

Re: [sqlalchemy] Invalidated Collection

2021-02-04 Thread Christian Henning
Thanks, Mike! I have some studying to do... On Wednesday, February 3, 2021 at 6:42:17 PM UTC-5 Mike Bayer wrote: > > > On Wed, Feb 3, 2021, at 6:23 PM, Christian Henning wrote: > > Hi Mike, > > thanks for your advice! I'll make the changes. > > But let me ask you one thing. My classmethod

Re: [sqlalchemy] SQLAlchemy (v.1.3.22) can not find Teradata engine inside Amazon Glue Job's script in Amazon environment

2021-02-04 Thread Simon King
Ah, OK, so the real problem is that the teradata package is trying to load a .so file from site-packages.zip and failing. This presumably happens when the module is imported, and Python is catching the underlying exception and raising an ImportError instead. It sounds like the teradata package is