7.32. Query Filter¶
Filter
Filter By
Where
7.32.1. Filter¶
7.32.2. Filter By¶
7.32.3. Where¶
>>> shrew = Animal(u'shrew')
>>> shrew[u'cuteness'] = 5
>>> shrew[u'weasel-like'] = False
>>> shrew[u'poisonous'] = True
>>>
>>> session.add(shrew)
>>> session.flush()
>>>
>>> q = (session.query(Animal).
... filter(Animal.facts.any(
... and_(AnimalFact.key == u'weasel-like',
... AnimalFact.value == True))))
>>> print('weasel-like animals', q.all())