开发者

filter_by usage problem in query building

开发者 https://www.devze.com 2023-04-03 16:37 出处:网络
I\'m having some trouble in using SQLAlchemy filter_by: for key in query_dict[\'filter\']: query = query.filter_by(key=query_dict[\'filter\'][key])

I'm having some trouble in using SQLAlchemy filter_by:

for key in query_dict['filter']:
                query = query.filter_by(key=query_dict['filter'][key])   
开发者_如何学运维

apparently, filter_by won't accept the argument because it can't find the column named 'key' <-- literally! in the table

Is there anyway around this? Oh btw, is there a good link to learn about query building and chaining of sqlalchemy? Thanks.


I think this should work just fine:

query = query.filter_by(**query_dict['filter'])
0

精彩评论

暂无评论...
验证码 换一张
取 消