Flask-SQLAlchemy database engine returns table names, but the table keys in metadata are empty Flask-SQLAlchemy database engine returns table names, but the table keys in metadata are empty flask flask

Flask-SQLAlchemy database engine returns table names, but the table keys in metadata are empty


Engine.table_names gives you a list of available table names from the database. Metadata.tables is a mapping of declared tables associated with the metadata.

If you want to populate the metadata with what's available in the database, use reflection:

db.metadata.reflect(bind=db.engine)