Re: [sqlalchemy] Adding where clause to existing SELECT without wrapping SELECT

2014-05-21 Thread gbr
Thanks to both of you for the pointers. Unfortunately, the way this is meant to work is not really an option for me. At current, I do sel2 = sel.where(literal(name = '%s' % thing)) to get around using a column reference. This works for now, but I was hoping for a better solution. I might have

Re: [sqlalchemy] Adding where clause to existing SELECT without wrapping SELECT

2014-05-21 Thread Michael Bayer
On May 21, 2014, at 2:02 AM, gbr doubl...@directbox.com wrote: Thanks to both of you for the pointers. Unfortunately, the way this is meant to work is not really an option for me. At current, I do sel2 = sel.where(literal(name = '%s' % thing)) to get around using a column reference.

Re: [sqlalchemy] Adding where clause to existing SELECT without wrapping SELECT

2014-05-20 Thread gbr
The above example is just a simplified version of the actual code. In fact, the construction of `sel` is much more difficult and `product_table` is actually a `select` made from multiple joins which only really exists within the function that creates `sel`. One wouldn't be able to reference it

Re: [sqlalchemy] Adding where clause to existing SELECT without wrapping SELECT

2014-05-20 Thread Michael Bayer
On May 19, 2014, at 9:12 PM, gbr doubl...@directbox.com wrote: I'm trying to modify a select statement which is fairly complex and which is created in a function that I don't want to modify. It is returned from this function and I'd like to add more WHERE clauses by just referencing the

[sqlalchemy] Adding where clause to existing SELECT without wrapping SELECT

2014-05-19 Thread gbr
I'm trying to modify a select statement which is fairly complex and which is created in a function that I don't want to modify. It is returned from this function and I'd like to add more WHERE clauses by just referencing the returned select statement. How can I do this without causing SQLA

Re: [sqlalchemy] Adding where clause to existing SELECT without wrapping SELECT

2014-05-19 Thread Ryan Kelly
Is there some issue with doing: sel2 = sel.where(product_table.c.name == water) ? If you really have no reference to the product_table, I think you can hack it with sel._raw_columns to try and find the column you want to filter to. -Ryan Kelly On Mon, May 19, 2014 at 9:12 PM, gbr