Fix Python – Difference between filter and filter_by in SQLAlchemy


Asked By – bodacydo

Could anyone explain the difference between filter and filter_by functions in SQLAlchemy?
Which one should I be using?

Now we will see solution for issue: Difference between filter and filter_by in SQLAlchemy


filter_by is used for simple queries on the column names using regular kwargs, like


The same can be accomplished with filter, not using kwargs, but instead using the ‘==’ equality operator, which has been overloaded on the object:


You can also write more powerful queries using filter, such as expressions like:


This question is answered By – Daniel

This answer is collected from stackoverflow and reviewed by FixPython community admins, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0