Instead of using filter_by
I would recommend using filter
, it gives you a lot more options.
For example (from the manual):
db.session.query(MyClass).filter(
MyClass.name == 'some name',
MyClass.id > 5,
)
In relation to your case:
filters = (
Transaction.amount > 10,
Transaction.amount < 100,
)
db.session.query(Transaction).filter(*filters)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…