Re: [sqlalchemy] Left join on one-to-many relationship with filters

2019-05-22 Thread Manoj Mokashi
Hi Michael, Thanks for the quick reply as usual. You have understood the use case correctly. Was aiming for DRY( don't repeat yourself) for the relation : once i declare the relation, i should not have to join to it again, to filter it. The transform looks useful. Another thing : Is it possible

Re: [sqlalchemy] Fast joins on multiple tables based on relationships

2019-05-22 Thread Mike Bayer
On Wed, May 22, 2019, at 10:29 PM, bvbav wrote: > Ok, so yes I see those queries for the two examples you posted. > > For my original model (first post), with dynamic it takes about 6sec to load > ~70,000 amount of data, going by the first post then this means all residents > and pets from an

Re: [sqlalchemy] Fast joins on multiple tables based on relationships

2019-05-22 Thread bvbav
Ok, so yes I see those queries for the two examples you posted. For my original model (first post), with dynamic it takes about 6sec to load ~70,000 amount of data, going by the first post then this means all residents and pets from an address. Which I would like to speed up. So I tried the

Re: [sqlalchemy] Fast joins on multiple tables based on relationships

2019-05-22 Thread Mike Bayer
On Wed, May 22, 2019, at 6:44 PM, bvbav wrote: > Thanks for replying, but your response doesn't really help. Perhaps my post > wasn't clear... not really sure, I answered what I thought I was seeing, and having gone through your new response, I am still seeing the same thing being asked, so

Re: [sqlalchemy] Fast joins on multiple tables based on relationships

2019-05-22 Thread bvbav
Thanks for replying, but your response doesn't really help. Perhaps my post wasn't clear... I'm aware the "dynamic" relationship returns a query, and not a collection. It's mainly used for large collections and when someone wants to perform filters, etc instead of getting the collection as a

Re: [sqlalchemy] Fast joins on multiple tables based on relationships

2019-05-22 Thread Mike Bayer
On Wed, May 22, 2019, at 3:56 PM, bvbav wrote: > Hi > > I was wondering if I can get some advice on this... > > Let's say I have these models: > > class Pet(db.Model): > id = db.Column(..., primary_key=True) > name = db.Column(...) > > > resident_pet = db.Table('resident_pet',

Re: [sqlalchemy] Conditional onupdate

2019-05-22 Thread Mike Bayer
On Wed, May 22, 2019, at 2:09 PM, Tony Cao wrote: > Sorry, I will clarify what I was asking. If I had my class example from above: > > class A(Base): > foo = Column(String) > bar = Column(String) > foo_updated = Column(DateTime, onupdate=update_fn) # Should only update when > foo is updated

[sqlalchemy] Fast joins on multiple tables based on relationships

2019-05-22 Thread bvbav
Hi I was wondering if I can get some advice on this... Let's say I have these models: class Pet(db.Model): id = db.Column(..., primary_key=True) name = db.Column(...) resident_pet = db.Table('resident_pet', db.Column('resident_id', db.Integer, db.ForeignKey('resident.id'),

Re: [sqlalchemy] Conditional onupdate

2019-05-22 Thread Tony Cao
Sorry, I will clarify what I was asking. If I had my class example from above: class A(Base): foo = Column(String) bar = Column(String) foo_updated = Column(DateTime, onupdate=update_fn) # Should only update when foo is updated Based on what information is in the context, sometimes

Re: [sqlalchemy] Left join on one-to-many relationship with filters

2019-05-22 Thread Mike Bayer
On Wed, May 22, 2019 at 1:02 AM Manoj Mokashi wrote: > > Hi Michael, > > It would be nice to have something like options(filterrelated(relation, > filter)) > That way, since the join is already specified in the relation, we don't have > to add it again. > Or is that difficult due to lazyloading