Someone
public text v1 · immutableSession = scoped_session(sessionmaker(autoflush=True, transactional=True))
engine = create_engine('mysql://')
# start request
connection = get_django_DBAPI_connection_from_wherever()
connection = sqlalchemy.engine.base.Connection(engine=engine, connection=connection, **possibly_other_stuff)
# set up thread-local Session bound to Connection
Session(bind=connection)
try:
# do request
finally:
Session.remove()