sqlalchemy动态组合查询语句。
Posted 上官飞鸿
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sqlalchemy动态组合查询语句。相关的知识,希望对你有一定的参考价值。
if filter_type == 1: search = and_(GameRoom.status ==1,or_( and_(GameRoom.white_user_id == user_id, GameRoom.active_player == 1), and_(GameRoom.black_user_id == user_id, GameRoom.active_player == 0))) elif filter_type == 2: search = and_(GameRoom.status ==1,or_( and_(GameRoom.white_user_id == user_id, GameRoom.active_player == 0), and_(GameRoom.black_user_id == user_id, GameRoom.active_player == 1))) elif filter_type == 3: search = GameRoom.create_by == user_id db.session.query(GameRoom).filter(search).all()
以上是关于sqlalchemy动态组合查询语句。的主要内容,如果未能解决你的问题,请参考以下文章
Mybatis -- 动态Sql概述动态Sql之<if>(包含<where>)动态Sql之<foreach>sql片段抽取
是否有使用 Sqlalchemy 的 Flask 动态查询构建器?