I want a query with multiple value like where id in (3,4,5)
Then I have a my_list = [3,4,5]
so how can I pass that list as an argument to filter in sqlalchemy?
query = Notification.query.filter_by(id=my_list).all()
Use in_ with filter:
query = Notification.query.filter(Notification.id.in_(my_list)).all()
Here's the relevant SO Q&A, and Read the Doc from sqlalchemy
In case Notification has a JSON field e.g. data, is there similar syntax to check a list e.g:
query = Notification.query.filter(Notification.data['key'].in_(my_list)).all()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With