Re: [sqlalchemy] Updates with GROUP BY and subquery

2016-08-12 Thread Rahul Ahuja
Got it, thanks! One last question if you have the time: for some reason it's looking at the wrong schema when parsing my UDF func.non_conflict_middlename in the update statement, despite parsing fine in the base query and subquery. I suspect that this is because my first table in the update

Re: [sqlalchemy] Updates with GROUP BY and subquery

2016-08-12 Thread Rahul Ahuja
Got it, thanks! One last question if you have the time: for some reason it's looking at the wrong schema when parsing my UDF func.non_conflict_middlename in the update statement, despite parsing fine in the base query and subquery. I suspect that this is because my first table in the update

Re: [sqlalchemy] Updates with GROUP BY and subquery

2016-08-12 Thread Rahul Ahuja
Got it, thanks! One last question if you have the time: for some reason it's looking at the wrong schema when parsing my UDF func.non_conflict_middlename in the update statement, despite parsing fine in the base query and subquery. I suspect that this is because my first table in the update

Re: [sqlalchemy] Updates with GROUP BY and subquery

2016-08-12 Thread Mike Bayer
it's a Core selectable so you need to use the .c. prefix - alias.c.columnname On 08/12/2016 02:03 PM, Rahul Ahuja wrote: Thank you so much for the reply! I'm almost there but am having trouble selecting the abms_biog.id column from my subquery - I'm getting an "AttributeError: 'Alias'

Re: [sqlalchemy] Updates with GROUP BY and subquery

2016-08-12 Thread Rahul Ahuja
Thank you so much for the reply! I'm almost there but am having trouble selecting the abms_biog.id column from my subquery - I'm getting an "AttributeError: 'Alias' object has no attribute 'abms_biog'" when I try: u = update(abms_biog) u = u.prefix_with("ignore", dialect="mysql")

Re: [sqlalchemy] Updates with GROUP BY and subquery

2016-08-12 Thread Mike Bayer
build an update out of abms_biog: stmt = update(abms_biog) use prefixes to get the "ignore" part: stmt = stmt.prefix_with("ignore", dialect="mysql") make sure your subquery is a Core selectable: subq = my_orm_query.subquery() add your subquery to the WHERE clause. e.g. the JOIN keyword

[sqlalchemy] Updates with GROUP BY and subquery

2016-08-11 Thread Rahul Ahuja
I'm trying to recreate the following SQL in SQLAlchemy: update ignore abms_biog a join (select a.id, u.id as user_id from abms_biog a join 3md.users u on u.firstname = a.firstname and u.lastname = a.lastname and 3md.non_conflict_middlename(u.middlename, a.middlename)=1 and u.credentials in