How to print all columns in SQLAlchemy ORM

后端 未结 10 2008
再見小時候
再見小時候 2020-12-28 15:18

Using SQLAlchemy, I am trying to print out all of the attributes of each model that I have in a manner similar to:

SELECT * from table;

How

10条回答
  •  南方客
    南方客 (楼主)
    2020-12-28 15:40

    Building on Rodney L's answer:

    model = MYMODEL
    columns = [m.key for m in model.__table__.columns]
    

提交回复
热议问题