Declarative Docs for Scoped Session are Incorrect

Issue #1010 resolved
Former user created an issue

It appears to me at least that the docs for using scoped session in the declarative docs is incorrect. I believe this:

engine = create_engine('postgres://scott:tiger@localhost/test')
Session = scoped_session(sessionmaker(transactional=True, autoflush=False, bind=engine))
Base = declarative_base()

should actually pass engine into the declarative_base or the metadata will not be bound:

engine = create_engine('postgres://scott:tiger@localhost/test')
Session = scoped_session(sessionmaker(transactional=True, autoflush=False, bind=engine))
Base = declarative_base(engine)

Comments (1)

  1. Mike Bayer repo owner

    the metadata doesn't need to be bound and its always misleading when we illustrate things that way, since people then assume this association is required. so we have to always talk about metadata binding to engine as an "optional" thing.

  2. Log in to comment