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