python - using list instead of number or string in the query -


I would like to use a list of the int used in a query in the following:

  db.define_table ('customer', region ('name'), area ('cusnumber', 'integer') def defytmr (): listOfNumbers = [22,12,76,98] qry = db (db . Customer.cusnumber == listOfNumbers). Selection (db.customer.name) Print Curie  

This is an issue that only the accepted data type in the query is int or str.

Is there any way to avoid this problem (preferably not being used for loop)

Regards

It's really hard to know what you are trying to ask, but the syntax of db.define_table (...) From, I guess a wild guess trying to do a query on web2py and your listOfNumbers get int .

You have the in the attribute as follows:

  # if all = true, cusnumber will need to include all the lists: Meaning any qry = db (db.customer.cusnumber.contains (listOfNumbers, all = false)) (db.customer.name)  

You can read more in the details In the

OP responded that contains only for string , I use for / loop I would like to suggest a better answer:

  listOfNu Mbers = [22,12,76,98] Number of folks in each list: qry = db (db.customer.cusnumber == each). Select (db.customer .name) # ... your stuff or whatever ...  

Comments

Popular posts from this blog

HTML/CSS - Automatically set height width from background image? -

php - Mysql Show Process - Sleep Commands and what to do -

c - What is the address of buf (the local variable in the main function)? -