Re: [sqlalchemy] Lazy load collection from a batch of objects with one query

2014-11-04 Thread Kevin S
Ah yes, perfect! The set_committed_value was the last piece I needed, to prevent lazy loading while setting the new values from the IN clause query. I like that DisjointEagerLoading recipe, as it pretty much captures the same idea. Oh, and perhaps I should say it again in case anyone in the fu

Re: [sqlalchemy] Lazy load collection from a batch of objects with one query

2014-11-04 Thread Michael Bayer
I was thinking of sqlalchemy-utils: https://github.com/kvesteri/sqlalchemy-utils , as I recall Konsta showing me the loader he wrote, but now I’m not seeing it here. I’ll keep poking around. You might want to take a look at the example for

Re: [sqlalchemy] Lazy load collection from a batch of objects with one query

2014-11-04 Thread Kevin S
Yes, I would say that is an acceptable solution to me. My current attempt, which I think might work, is to grab all the primary keys off the original list of objects, then use those on an IN clause where I load only the primary key (by deferring everything else) of the parent and the desired co

Re: [sqlalchemy] Lazy load collection from a batch of objects with one query

2014-11-03 Thread Michael Bayer
Well to load multiple collections at once you need to give a list of parent instances, were you hoping it would use an IN to achieve that or otherwise what SQL are you looking for? There is a 3rd party extension which does some of this and I was hoping to someday implement the IN style of load

Re: [sqlalchemy] Lazy load collection from a batch of objects with one query

2014-11-03 Thread Kevin S
Ok, I think I understand some of the reasoning behind not wanting to implement such a feature. I think this is fine, because I don't need the magic that hibernate provides. However, I'm still stuck with the current problem of how to do this kind of collection populating with our antique sybase

Re: [sqlalchemy] Lazy load collection from a batch of objects with one query

2014-11-01 Thread Michael Bayer
> On Nov 1, 2014, at 11:53 AM, Kevin S wrote: > > I think I've seen this sort of functionality in Hibernate, where it tries to > optimize if you are going to access some lazy loaded property on a collection > of objects. It can load them in batches, as opposed to one query for every > object.

[sqlalchemy] Lazy load collection from a batch of objects with one query

2014-11-01 Thread Kevin S
I think I've seen this sort of functionality in Hibernate, where it tries to optimize if you are going to access some lazy loaded property on a collection of objects. It can load them in batches, as opposed to one query for every object. So, I'm asking if there is any way to do something like