Re: [sqlalchemy] Modifying results of a KeyedTuple query?

2018-08-10 Thread Mike Bayer
On Fri, Aug 10, 2018, 5:24 PM James Couch wrote: > Oops, I missed the part about the bulk update. I suppose that would work > as long as it's keying on the index. The documentation doesn't make it > clear how it picks the index to query on... I assume it inspects the column > properties and

Re: [sqlalchemy] Modifying results of a KeyedTuple query?

2018-08-10 Thread James Couch
Oops, I missed the part about the bulk update. I suppose that would work as long as it's keying on the index. The documentation doesn't make it clear how it picks the index to query on... I assume it inspects the column properties and picks the best one to use behind the scenes? Normally you'd

Re: [sqlalchemy] Modifying results of a KeyedTuple query?

2018-08-10 Thread James Couch
I think I see what you mean. Do an inline query/update, maybe just query by primary index for speed. I guess that won't add too much overhead, I'll give it a shot. On Friday, August 10, 2018 at 1:43:51 PM UTC-5, Mike Bayer wrote: > > You need to copy the keyedtuples into some other data

Re: [sqlalchemy] Modifying results of a KeyedTuple query?

2018-08-10 Thread James Couch
On Friday, August 10, 2018 at 4:03:06 PM UTC-5, Jonathan Vanasco wrote: > > > A quick background on Mike's short answer... Tuples are immutable lists in > Python, and "KeyedTuple" should indicate that you can't change the values. > They're just a handy result storage object, not an ORM object

Re: [sqlalchemy] Modifying results of a KeyedTuple query?

2018-08-10 Thread Jonathan Vanasco
On Friday, August 10, 2018 at 2:43:51 PM UTC-4, Mike Bayer wrote: > > You need to copy the keyedtuples into some other data structure, like a > dictionary, modify it, then send that data back into updates. Your best > bet is to use the bulk update stuff once you have those dictionaries, see

Re: [sqlalchemy] Modifying results of a KeyedTuple query?

2018-08-10 Thread Mike Bayer
You need to copy the keyedtuples into some other data structure, like a dictionary, modify it, then send that data back into updates. Your best bet is to use the bulk update stuff once you have those dictionaries, see

[sqlalchemy] Modifying results of a KeyedTuple query?

2018-08-10 Thread James Couch
Hey all. Long time lurker, first time poster. I'm using sqlalchemy ORM. We have a fairly decent sized data set, and one table has a pretty large number of columns, some of them with foreignkeys. I found that limiting a query to specific columns speeds up the time it takes to come back with a