0

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?

1 Answer 1

1

Use in_ to create SQL IN clause.


models.s.query(models.User).filter(models.User.location.in_(offices)).all()

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.