All pastes #945256 Raw Edit

Someone

public text v1 · immutable
·published 2008-03-16 20:18 UTC
rendered paste body
Session = 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()