When you want to write a query in Python
that will select (from SQLite
database) all the books that have 300 pages, you will write:
numsPages = 300
cur.execute("select * from books where number_of_pages = :numsPages", locals())
The problem is when you want to select books that have number of pages from certain set
lst = computeListFromVariousInputs() # lst is list containing natural numbers
cur.execute("select * from books where number_of_pages in :lst", locals())
The above statement is not possible.
It's difficult to write many or
operators in the statement, so I'd like to use rather the in
operator.
How would you write the query without using many or
operators and using some Python
list or other data structure?
Maybe, the example seems not practical (and it is) but this question is more understandable when I use this example.