I am trying to create a program that stores
- Fruit name
- Fruit type
- Fruit color
- Fruit size
and return them to the user upon request. The user will be provided with predefined selection options. Something like that:

My database table will look like this:

Now I am trying to implement a filter function that allows the user to select
- Fruit type
- Fruit color
- Fruit size
And it will return all Fruit Names that have the above properties. But now I have an additional option "Everything".

Assuming I already requested data for all fruits and saved them in a dictionary as follows:
myfruits = { 'apple':('fleshy','red','medium'), 'orange':('fleshy','orange','medium'), 'peanut':('dry','red','small'),...}
How to get a list of fruit names that has three properties that the user has selected? (For example, if the user selected the "fleshy" type, "All", "All" - he should return ['apple','orange'] .)
I thought about using an if , but as the number of properties grows, I would have to write so many if and else lines that I think are unthinkable.
I am using Python 2.7 with PyQt 4 and SQLite 3 on a 32-bit version of Windows XP XP SP3.
python filter logic sqlite3 pyqt
Chris aung
source share