Listing indices using sqlalchemy
Is it possible to list all indices in a db 开发者_运维知识库using sqlalchemy?
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
精彩评论