Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Listing indices using sqlalchemy

Is it possible to list all indices in a db using sqlalchemy?

like image 787
banx Avatar asked Apr 09 '11 12:04

banx


1 Answers

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
like image 162
nosklo Avatar answered Oct 01 '22 18:10

nosklo