Reputation: 3202
I've got a Flask app and I'm trying to get a SQLalchemy query using OR to return two different status like this but in one query:
csv_list_1 = csvTable.query.filter_by(file_uuid=file_uuid).filter_by(status="Validated")
csv_list_2 = csvTable.query.filter_by(file_uuid=file_uuid).filter_by(status="Also Validated")
I've found a couple of answers on stack overflow but trying the following:
from sqlalchemy import or_
csv_list = csvTable.query.filter_by(file_uuid=file_uuid).filter_by(or_(status="Validated", status="Also Validated"))
I get:
SyntaxError: keyword argument repeated
I'm not sure where to go from here.
Upvotes: 0
Views: 320
Reputation: 10090
Your column names shouldn't be keyword arguments here, it should be a boolean check like this:
csv_list = csvTable.query.filter_by(file_uuid=file_uuid)\
.filter(or_(status == "Validated", status == "Also Validated"))
Upvotes: 2