SQLAlchemy declarative syntax with autoload (reflection) in Pylons

后端 未结 4 1718
日久生厌
日久生厌 2020-12-16 01:57

I would like to use autoload to use an existings database. I know how to do it without declarative syntax (model/_init_.py):

def init_model(engine):         


        
4条回答
  •  失恋的感觉
    2020-12-16 02:17

    Check out the Using SQLAlchemy with Pylons tutorial on how to bind metadata to the engine in the init_model function.

    If the meta.Base.metadata.bind(engine) statement successfully binds your model metadata to the engine, you should be able to perform this initialization in your own init_model function. I guess you didn't mean to skip the metadata binding in this function, did you?

提交回复
热议问题