[sqlalchemy] Re: How to query for something like this?

2015-09-22 Thread Yegor Roganov
Just do it in Python: res = [] for hpoint in session.query(HistoryPoint).all(): res.setdefault(hpoint.vehicle_id, []).append({'id':hpoint.id,'location': str(hpoint.location)}) On Tuesday, September 22, 2015 at 6:48:14 PM UTC+3, Johnny W. Santos wrote: > > Supose I have the models below, how

[sqlalchemy] Re: How to query for something like this?

2015-09-22 Thread Yegor Roganov
Correction: res = {} for hpoint in session.query(HistoryPoint).all(): res.setdefault(hpoint.vehicle_id, []).append({'id':hpoint.id,'location': str(hpoint.location)}) But it will yield a dict, not an array of single-value dicts as requested (are you sure this is what you want? anyways, it's

Re: [sqlalchemy] Re: How to query for something like this?

2015-09-22 Thread Johnny W. Santos
Anyway thanks, it'll help a lot. -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to

Re: [sqlalchemy] Re: How to query for something like this?

2015-09-22 Thread Johnny W. Santos
Yes, but I think this will be expensive to arrange it with python because I need to return everything at once. I though I could just group_by with some annotation, but I couldn't figure out how. -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To