Sqlalchemy - 组合查询
程序员文章站
2024-03-02 21:54:52
...
-
or_、and_(需要额外导入:
from sqlalchemy.sql import or_,and_
) - in_([1,2,3,4,5])
- ~in_([1,2,3,4,5]) = notin_([1,2,3,4,5])
- between(1,3)
- ~between(1,3)
- order_by(xxx.desc()/asc())
- db_session.query(Student.student_id.label("xh"),Student.name).filter(...)
res = db_session.query(Student.student_id.label("xh"),Student.name).\
filter(or_(Student.student_id==179074001,Student.student_id==279074001)).\
order_by(Student.student_id.desc()).all()