You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
nog.infio.mirror/src/Controlers/SessionRunner.py

24 lines
613 B

### another way (but again *not the only way*) to do it ###
from contextlib import contextmanager
@contextmanager
def session_scope():
"""Provide a transactional scope around a series of operations."""
session = Session()
try:
yield session
session.commit()
except:
session.rollback()
raise
finally:
session.close()
#all session.add will be done in session_scope(). tbd: remove individual commits from ORM_test.py
def run_my_program():
with session_scope() as session:
pass
#ThingOne().go(session)
#ThingTwo().go(session)