Thanks But i get input as [['a==b'],'and', [<object of sqlalchemmy binary expression>],'and','(', ['x==y'],'or',['t==y'],')']
for a==b and id in(1,2,3,4,5) and (x==y or t==y) Now from this ;list input i want to make the where expression. I tried making all to the string but the objects (binary expression) create problem. On Jun 26, 5:16 pm, "King Simon-NFHD78" <simon.k...@motorola.com> wrote: > > On Jun 23, 3:32 pm, Ash <ashishsinghbha...@gmail.com> wrote: > > > Hello, > > > > I am tryin to make the dynamic where clause using > > append_whereclause. > > > > But how i can do that, For eg : > > > > I have a==b and c in (1,2,3,4) or d like %s > > > > So i made three sqlalchemy expression > > > > 1. a==b > > > 2. c in (1,2,3,4) [ using in_] > > > 3. d like %s [using like] > > > > now i want this 3 to stuff in where clause . > > > > I created select like sel = select() > > > > How can i make the where clause which have and and or both uisng > > > append_whereclause. > > I think append_whereclause always uses AND, so you need to connect these > conditions into a single clause and call append_whereclause just once. > > It's not clear how you want the grouping of your conditions to work. Is it: > > (a==b AND c in (1, 2, 3, 4)) OR d like %s > > Or > > a==b AND (c in (1, 2, 3, 4) OR d like %s) > > I think you need to do something like this (for the first option): > > from sqlalchemy import and_, or_ > > clause = or_(and_(a == b, c.in_([1, 2, 3, 4])), > d.like(something)) > sel.append_whereclause(clause) > > You may also be able to use the '&' and '|' operators, as long as you are > careful with brackets. See the docs > athttp://www.sqlalchemy.org/docs/05/sqlexpression.html#conjunctions > > Hope that helps, > > Simon --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---