I want to use the Metadata object to get information about my definitions (i.e., my Model objects) as well as going out to the actual database. But no matter what I try, it always uses the defined information and not what’s in the database.
Here’s what I have
engine = create_engine('...')
class ModelBase(DeclarativeBase):
pass
metadata = ModelBase.metadata
print(metadata.tables.keys())
Even if I delete tables from the database, it still prints the names of the tables as they are defined.
I have tried using metadata.reflect(bind=engine)
, but that doesn’t seem to have any affect. Are there two different metadata objects, or 2 different ways to create the object?
I want to be able to compare my definitions with what is in the actual database