是否可以使用sqlalchemy列出数据库中的所有索引?

最佳答案


from sqlalchemy import create_engine
from sqlalchemy.engine import reflection
engine = create_engine('...')
insp = reflection.Inspector.from_engine(engine)
for name in insp.get_table_names():
    for index in insp.get_indexes(name):
        print index

09-26 22:48