使用sqlalchemy列出索引

时间:2011-04-09 12:26:49

标签: python sql indexing sqlalchemy

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

1 个答案:

答案 0 :(得分:3)

yes

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