for example, I'd like to search for keywords "foo", "bar" and possibly but 
not necessarily more keywords in the "description" column of my *Item* class, 
so I build a list of such keywords:
["foo", "bar"],

and then use primitive looping to achieve my goal:

query_obj = session.query(Item)
for k in search_keywords:
    query_obj = query_obj.filter(Item.description.like('%{0}%'.format(k)))

but this doesn't seem very elegant. I think there could be a better 
solution in sqlalchemy. Could someone share some tips other than looping 
and chaining? Thanks.

p.s. Also what is the best practice to achieve a "OR" search of 
multiple(indefinite number of) keywords?

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to