All tables are collected in the tables attributes of the SQLAlchemy MetaData object. To get a list of the names of these tables:
>>> metadata.tables.keys() ['posts', 'comments', 'users']
If you use a declarative extension, you probably do not manage the metadata yourself. Fortunately, metadata is still present in the base class,
>>> Base = sqlalchemy.ext.declarative.declarative_base() >>> Base.metadata MetaData(None)
If you are trying to figure out which tables are in your database, even among those that you have not even talked about SQLAlchemy about, then you can use table reflection. Then, SQLAlchemy will check the database and update the metadata with all the missing tables.
>>> metadata.reflect(engine)
SingleNegationElimination Jun 24 '11 at 21:40 2011-06-24 21:40
source share