python - What's the difference between filter and filter_by in SQLAlchemy? -
Do any difference in SQLAlchemy in any filter
and filter_by
function Can explain? I am confused and can not really see the difference, which one should I use?
filter_by
is used for simple questions
db.users.filter_by (name = 'joe')
This way the filter can be completed with
, of the quad , But instead using the '==' equality operator, which is overloaded on the db.users.name object:
db.users.filter (Db.users .name == 'Joe')
You can also write more powerful questions by using the filter
Expressions:
db.users.filter (or_ (db.users.name == 'Ryan', db.users.country == 'England'))
Comments
Post a Comment