I am having a bit of trouble getting DeferredReflection working the way I want; not sure if I am overlooking something obvious or if I just don't really understand how it's supposed to work.
I'm trying to define my models before creating my engine (this does not work): Base = declarative_base(cls=*DeferredReflection*) class CityStats(Base): __tablename__ = 'city_stats' __table_args__ = {'schema': 'prod', *'autoload': True*} if __name__ == '__main__': engine = create_engine('...') Base.metadata.bind = engine Base.prepare(engine) When I run this I get an error creating the CityStats class: "sqlalchemy.exc.UnboundExecutionError: No engine is bound to this Table's MetaData. Pass an engine to the Table via autoload_with=<someengine>, or associate the MetaData with an engine via metadata.bind=<someengine>" Of course it does work if I create my engine and set Base.metadata.bind BEFORE I define the CityStats model (this works): engine = create_engine('...') Base.metadata.bind = engine class CityStats(Base): __tablename__ = 'city_stats' __table_args__ = {'schema': 'prod', *'autoload': True*} Base.prepare(engine) I'm trying to avoid some kind of model_init() function that everyone who imports my models.py file will have to remember to call before importing my models. Is this possible? -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/groups/opt_out.