Search code examples
pythonsqlalchemypyramid

Fetch all records but some condition on filed in SQLAlchemy?


I need select * from new_entry where batch=2018. I tried query.filter(NewEntry.batch==batch).first() i got first record in database but i need all columns which is matched to batch.What can I do?


Solution

  • Since you are using first() you will only get the first result, to get all the results as a list you have to use all()

    query.filter(NewEntry.batch==batch).all()