How to discover table properties from SQLAlchemy mapped object

前端 未结 2 1605
南旧
南旧 2020-11-30 03:45

I have a class mapped with a table, in my case in a declarative way, and I want to \"discover\" table properties, columns, names, relations, from this class:



        
2条回答
  •  醉梦人生
    2020-11-30 04:48

    Information you need you can get from Table object:

    • Ship.__table__.columns will provide you with columns information
    • Ship.__table__.foreign_keys will list foreign keys
    • Ship.__table__.constraints, Ship.__table__.indexes are other properties you might find useful

提交回复
热议问题