Re: [sqlalchemy] replacing a filter attribute, or iterating over a booleanclauselist?

2016-03-04 Thread Ladislav Lenart
Hello. I responded yesterday but it seems the mail did not make it. Here it goes and sorry for the duplicate... On 3.3.2016 21:09, Ladislav Lenart wrote: > Hello. > > > On 3.3.2016 19:52, Brian Cherinka wrote: >> Yeah, that might ultimately be the best way to go if things get too >>

Re: [sqlalchemy] replacing a filter attribute, or iterating over a booleanclauselist?

2016-03-03 Thread Brian Cherinka
Yeah, that might ultimately be the best way to go if things get too complicated. I think people might not want to re-run several lines of code to change some parameters but that could be a thing I make them just live with. On Thursday, March 3, 2016 at 3:06:57 AM UTC-5, Ladislav Lenart

Re: [sqlalchemy] replacing a filter attribute, or iterating over a booleanclauselist?

2016-03-03 Thread Ladislav Lenart
Hello. I think it would be (much) easier to simply rebuild the query from scratch before each run. IMHO the time to build the query is not that big a factor to justify the added source code complexity. HTH, Ladislav Lenart On 3.3.2016 05:47, Brian Cherinka wrote: > > > well you need a

Re: [sqlalchemy] replacing a filter attribute, or iterating over a booleanclauselist?

2016-03-02 Thread Brian Cherinka
Also, I've noticed that when you update the bindparams q = q.params(x='1234') and then try to print the whereclause, the parameters are not updated. Yet in the statement, they are updated. print q.query.whereclause.compile(dialect=postgresql.dialect(),compile_kwargs={'literal_binds':True})

Re: [sqlalchemy] replacing a filter attribute, or iterating over a booleanclauselist?

2016-03-02 Thread Brian Cherinka
> > > > well you need a list of names so from a mapped class you can get: > > for name in inspect(MyClass).column_attrs.keys(): > if name in : > q = q.filter_by(name = bindparam(name)) > > though I'd think if you're dynamically building the query you'd have the > values already,

Re: [sqlalchemy] replacing a filter attribute, or iterating over a booleanclauselist?

2016-03-02 Thread Mike Bayer
On 03/02/2016 04:59 PM, Brian Cherinka wrote: Thanks, Mike. This is excellent. That did the trick. That's much easier than what I was trying to do. Do you know if there is a way to auto bindparam every parameter I have in my Declarative Bases, if and when they get added into a filter?

Re: [sqlalchemy] replacing a filter attribute, or iterating over a booleanclauselist?

2016-03-02 Thread Brian Cherinka
I'm essentially building a tool for a group that doesn't know SQLalchemy, and doesn't want to know or care about it, or even SQL in general. They need to be able to query a dataset using minimal input, namely only caring about the input filter conditions (e.g. X > 10). Presumably, they will

Re: [sqlalchemy] replacing a filter attribute, or iterating over a booleanclauselist?

2016-03-02 Thread Brian Cherinka
I'm essentially building a tool for a large group of people that don't know SQLalchemy, and will never care enough or want to know, about SQLalchemy or SQL in general. And they need to be able to build queries to the dataset based on really minimal information. All they would input are

Re: [sqlalchemy] replacing a filter attribute, or iterating over a booleanclauselist?

2016-03-02 Thread Simon King
Out of interest, how are you building your query, and why do you need to be able to change the values afterwards? Simon > On 2 Mar 2016, at 21:59, Brian Cherinka wrote: > > Thanks, Mike. This is excellent. That did the trick. That's much easier > than what I was

Re: [sqlalchemy] replacing a filter attribute, or iterating over a booleanclauselist?

2016-03-02 Thread Brian Cherinka
Thanks, Mike. This is excellent. That did the trick. That's much easier than what I was trying to do. Do you know if there is a way to auto bindparam every parameter I have in my Declarative Bases, if and when they get added into a filter? Basically, I need to allow the user to be able to

Re: [sqlalchemy] replacing a filter attribute, or iterating over a booleanclauselist?

2016-03-02 Thread Mike Bayer
On 03/02/2016 03:29 PM, Brian Cherinka wrote: Hi, After a query has been constructed with some filter conditions applied, but before the query has been run, what's the best way to replace the attribute in the filter clause? Let's say I have a query like this | q

[sqlalchemy] replacing a filter attribute, or iterating over a booleanclauselist?

2016-03-02 Thread Brian Cherinka
Hi, After a query has been constructed with some filter conditions applied, but before the query has been run, what's the best way to replace the attribute in the filter clause? Let's say I have a query like this q = session.query(Cube).join(Version).filter(Version.version == 'v1_5_1') and