Re: [sqlalchemy] Generating Correlated Subqueries

2015-04-23 Thread ThereMichael
On Sunday, April 19, 2015 at 7:08:41 PM UTC-4, Michael Bayer wrote: If I want *all* of the Thing object, I change it to this: q = s.query(Thing, func.count(Comment.type)).\ filter(Thing.creation = datetime.date(2015, 4, 19)).\ filter(Thing.creation datetime.date(2015, 4, 26)).\

Re: [sqlalchemy] Generating Correlated Subqueries

2015-04-19 Thread ThereMichael
Sorry, sometimes you get so deep into something you forget everyone else isn't familiar with the problem. As an example, here's what I'm looking for: select things.id, count(comments.type) from things things, comments comments where things.creation = 2015-04-19 and things.creation

Re: [sqlalchemy] Generating Correlated Subqueries

2015-04-19 Thread Mike Bayer
On 4/19/15 9:36 AM, ThereMichael wrote: Sorry, sometimes you get so deep into something you forget everyone else isn't familiar with the problem. As an example, here's what I'm looking for: select things.id, count(comments.type) from things things, comments comments where

Re: [sqlalchemy] Generating Correlated Subqueries

2015-04-19 Thread Mike Bayer
On 4/19/15 10:16 AM, ThereMichael wrote: Ok, that worked perfectly! If I want /all/ of the Thing object, I change it to this: q = s.query(Thing, func.count(Comment.type)).\ filter(Thing.creation = datetime.date(2015, 4, 19)).\ filter(Thing.creation datetime.date(2015, 4, 26)).\

Re: [sqlalchemy] Generating Correlated Subqueries

2015-04-19 Thread Mike Bayer
On 4/19/15 9:56 AM, Mike Bayer wrote: On 4/19/15 9:36 AM, ThereMichael wrote: Sorry, sometimes you get so deep into something you forget everyone else isn't familiar with the problem. As an example, here's what I'm looking for: select things.id, count(comments.type) from things

Re: [sqlalchemy] Generating Correlated Subqueries

2015-04-19 Thread ThereMichael
Ok, that worked perfectly! If I want *all* of the Thing object, I change it to this: q = s.query(Thing, func.count(Comment.type)).\ filter(Thing.creation = datetime.date(2015, 4, 19)).\ filter(Thing.creation datetime.date(2015, 4, 26)).\ filter(Comment.target_id == Thing.id).\

Re: [sqlalchemy] Generating Correlated Subqueries

2015-04-18 Thread Mike Bayer
On 4/18/15 7:13 PM, Michael Wilson wrote: I have the following tables: things_table = Table(’thing', self.metadata, Column('id', Integer, primary_key=True), … ) comments_table = Table('comments', self.metadata, Column('id', Integer, primary_key=True), # Unique id for this

[sqlalchemy] Generating Correlated Subqueries

2015-04-18 Thread Michael Wilson
I have the following tables: things_table = Table(’thing', self.metadata, Column('id', Integer, primary_key=True), … ) comments_table = Table('comments', self.metadata, Column('id', Integer, primary_key=True), # Unique id for this comment Column('type',