Re: [sqlalchemy] Confusion over session.dirty, query, and flush

2018-09-26 Thread Jonathan Vanasco
On Wednesday, September 26, 2018 at 10:08:43 PM UTC-4, jens.t...@gmail.com wrote: > > > Suppose I get the “new”, “dirty”, and “deleted” sets as per discussion > below, and I’m especially interested in the “dirty” set: is there a way to > find out which properties of an object were modified,

Re: [sqlalchemy] Confusion over session.dirty, query, and flush

2018-09-26 Thread jens . troeger
I’d like to pick up this topic once more briefly. Suppose I get the “new”, “dirty”, and “deleted” sets as per discussion below, and I’m especially interested in the “dirty” set: is there a way to find out which properties of an object were modified, or only that the object was modified?

Re: [sqlalchemy] Hybrid property with subquery

2018-09-26 Thread YKdvd
I think that got me to where I have a working hybrid. It looks something like this (I broke it up into multiple statements for debugging): @isLast.expression def isLast(cls): dmsq = aliased(dm, name="dmsq") q = cls.id == select([dmsq.id]).where(dmsq.department_id ==

Re: [sqlalchemy] Primary key set on object after rollback

2018-09-26 Thread Mike Bayer
On Wed, Sep 26, 2018 at 10:05 AM Doug Miller wrote: > > Thanks. This occurs on create/insert so I would probably remove all primary > keys. Is there a reason why a handler would work better here? I’d prefer to > keep my logic central and avoid callbacks if possible. the event handlers are just

Re: [sqlalchemy] Primary key set on object after rollback

2018-09-26 Thread Doug Miller
Thanks. This occurs on create/insert so I would probably remove all primary keys. Is there a reason why a handler would work better here? I’d prefer to keep my logic central and avoid callbacks if possible. -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper

Re: [sqlalchemy] Primary key set on object after rollback

2018-09-26 Thread Mike Bayer
On Wed, Sep 26, 2018 at 9:26 AM Mike Bayer wrote: > > On Tue, Sep 25, 2018 at 9:09 PM Doug Miller wrote: > > > > I think my issue is that before the commit/rollback > > Alice.id is None but after Alice.id is set to some integer. I understand > > the object is transient but I wish that the

Re: File logger fails when used with a Gunicorn/Pyramid .ini file.

2018-09-26 Thread Mike Bayer
On Wed, Sep 26, 2018 at 4:43 AM wrote: > > I haven’t used env.py before, you’re talking about this: > https://pypi.org/project/env.py/ , correct? env.py is an integral part of your Alembic project space and you are using it. Please see the tutorial at

Re: [sqlalchemy] Primary key set on object after rollback

2018-09-26 Thread Mike Bayer
On Tue, Sep 25, 2018 at 9:09 PM Doug Miller wrote: > > I think my issue is that before the commit/rollback > Alice.id is None but after Alice.id is set to some integer. I understand the > object is transient but I wish that the primary key field was not modified in > this way because if I want

Re: [sqlalchemy] Re: How to update a SQLAlchemy database object correctly (test data set and code included).

2018-09-26 Thread Simon King
No problem. By the way, I noticed a bug in my code, on this line: origin_species = session.query(Species).filter_by(name=origin_latin_name).one() You probably want ".first()" rather than ".one()". "first()" will either return a matching Species object or None, whereas "one()" checks that the

Re: File logger fails when used with a Gunicorn/Pyramid .ini file.

2018-09-26 Thread jens . troeger
I haven’t used env.py before, you’re talking about this: https://pypi.org/project/env.py/ , correct? On Wednesday, September 26, 2018 at 10:06:31 AM UTC+10, Mike Bayer wrote: > > oh, you know that's in the logging. logging.fileConfig() is used for > that and it's actually in your env.py. Just

[sqlalchemy] Re: How to update a SQLAlchemy database object correctly (test data set and code included).

2018-09-26 Thread Ioannes
Thank you so much for this detailed response. I really appreciate it, the explanation and example really furthered my understanding and where I was going wrong. On Sunday, September 23, 2018 at 9:05:36 PM UTC+1, Ioannes wrote: > > Hi all, > > I had originally asked a question here: >