Reputation: 723
I have a SQLAlchemy query in python where I want to filter output if a column value exists in a locally created array. However, this always returns None.
offices = ['US', 'UK', 'MEX']
users_db = models.s.query(models.User).filter(models.User.location in offices).all()
Is there a different implementation to that in SQLAlchemy or am I doing something wrong?
Upvotes: 0
Views: 398
Reputation: 9039
Use in_
to create SQL IN
clause.
models.s.query(models.User).filter(models.User.location.in_(offices)).all()
Upvotes: 1