SQLAlchemy - Getting a list of tables

前端 未结 9 1184
青春惊慌失措
青春惊慌失措 2020-12-08 03:40

I couldn\'t find any information about this in the documentation, but how can I get a list of tables created in SQLAlchemy?

I used the class method to create the tab

9条回答
  •  悲哀的现实
    2020-12-08 04:18

    Reflecting All Tables at Once allows you to retrieve hidden table names too. I created some temporary tables and they showed up with

    meta = MetaData()
    meta.reflect(bind=myengine)
    for table in reversed(meta.sorted_tables):
        print table
    

    Reference http://docs.sqlalchemy.org/en/latest/core/reflection.html

提交回复
热议问题