python - How to dynamically create where clauses given a list of parameters? -


Would it be possible to dynamically add filters to a given PEVB selection statement? Instead of an example:

  table. Selection () Paginated (page, ENTRY_PER_PAGE). Where ((Table.Base == Base1) & amp; (table .base == base2) & amp; ...   

I have a list I say, and it filters in content in that list :

  list = [base1, base2, base3 ...] table. Selection () Paginated (page, ENTRY_PER_PAGE). Where ((Table.Base == contentfromlist))    

you (Python 3.x ):

  & gt; & Gt; & Gt; Import operator & gt; & Gt; & Gt; Reduce (operator.most, [2, 3, 5]) 30> and gt; & Gt; Generator expression:  
  with base_list = [base1, base2, base3] table. 3 * 5 30   

table. Selection () Paginated (page, operator. And _ (instead of

)

(operator.and, code> operator .__ and __ ), if you need to express a more complex expression, you can also use it:

  ... reduce (lambda a, b : A and B, (table.base == b in base_list b)) ...    

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -