from sqlalchemy orm import scoped_session from sqlalchemy orm import s

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
from sqlalchemy.orm import scoped_session
from sqlalchemy.orm import sessionmaker
session_factory = sessionmaker(bind=some_engine)
Session = scoped_session(session_factory)
def thread():
some_session = Session()
# do my staff
Session.remove()