SQLAlchemy ORM: modify the columns returned from a query

后端 未结 2 1199
刺人心
刺人心 2021-01-12 07:24

If I\'ve got an SQLAlchemy ORM query:

admin_users = Session.query(User).filter_by(is_admin=True)

Is it possible to modify the columns retur

2条回答
  •  情深已故
    2021-01-12 08:01

    I feel your pain on the values() thing. In 0.6.5 I added with_entities() which is just like values() except doesn't iterate:

    q = q.with_entities(User.id)
    

提交回复
热议问题