Tuesday, January 28, 2014

SQLalchemy - Print Tables In Database (Show Tables)

from sqlalchemy import create_engine, Table, MetaData

engine = create_engine('mysql+mysqldb://username:password@111.111.111.111/databaseName')
metadata = MetaData(bind=engine)
metadata.reflect(engine)
print metadata.tables.keys()

You could also use that for looping through a list of the tables in the database.

No comments:

Post a Comment