SQLAlchemy 别名

我们在聚合或者字段名很长的时候我们就可以来使用别名

别名的使用方法 label :

result = pg_conn.query(GeographyAffiliation.location,
                       func.sum(GeographyAffiliation.count).label("count")).filter(
                       *filters).group_by(GeographyAffiliation.location).all()

 

posted @ 2020-12-23 18:33  你的小可爱吖  阅读(1552)  评论(0编辑  收藏  举报