SQLalchemy - Print Tables In Database (Show Tables)
Updated 2026-09-23: updated the code for SQLAlchemy 2.0 and Python 3.
from sqlalchemy import create_engine, Table, MetaData
engine = create_engine('mysql+mysqldb://username:password@198.51.100.1/databaseName')
metadata = MetaData()
metadata.reflect(bind=engine)
print(metadata.tables.keys())
You could also use that for looping through a list of the tables in the database.