CONCAT_WS in sqlalchemy?

可紊 提交于 2019-12-12 06:44:59

问题


In my sqlobject implementation I have the following line:

members = Member.select("CONCAT_WS(' ', member.first_name, member.last_name, member.personal_code_number, member.mail) like " + Member.sqlrepr('%' + query + '%'))

I want to convert that to using sqlalchemy but haven't found a way to do that.


回答1:


members = session.query(Member).filter(
    func.CONCAT_WS(' ', Member.first_name, Member.last_name, Member.personal_code_number, Member.mail)
    .like('%' + query + '%')
)


来源:https://stackoverflow.com/questions/20914464/concat-ws-in-sqlalchemy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!