8.32. SQLAlchemy Query Filter
Filter
Filter By
Where
8.32.1. Filter
8.32.2. Filter By
8.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())