SqlAlchemy: case语句(case - if - then -else)

时间:2022-11-01 22:25:46

I'm wondering if there's a way to create a case statement with SqlAlchemy, e.g. the postgresql version

我想知道是否有一种方法可以用SqlAlchemy创建case语句,例如postgresql版本

Maybe literal SQL is the way to go if there is no easy way of doing it?

如果没有简单的方法,那么文字SQL可能是最好的方法。

1 个解决方案

#1


10  

Check out the documentation about the case statement here: http://docs.sqlalchemy.org/en/latest/core/sqlelement.html#sqlalchemy.sql.expression.case

查看关于case语句的文档:http://docs.sqlalchemy.org/en/latest/core/sqlelement.html#sqlalchemy.sql.expression.case

#1


10  

Check out the documentation about the case statement here: http://docs.sqlalchemy.org/en/latest/core/sqlelement.html#sqlalchemy.sql.expression.case

查看关于case语句的文档:http://docs.sqlalchemy.org/en/latest/core/sqlelement.html#sqlalchemy.sql.expression.case