def teardown(): session = Session() map(session.delete, session.query(A)) map(session.delete, session.query(B)) map(session.delete, session.query(models.Operation)) map(session.delete, session.query(models.Version)) session.commit()
def changestuff(): session = Session() a1, a2 = session.query(A) b1, b2, b3 = session.query(B) a1.name = "first a modified" b2.a = a2 session.delete(b3) session.commit()
def addstuff(): a1 = A(name="first a") a2 = A(name="second a") b1 = B(name="first b", a=a1) b2 = B(name="second b", a=a1) b3 = B(name="third b", a=a2) session = Session() session.add_all([a1, a2, b1, b2, b3]) session.commit()
def teardown(): session = Session() for a in session.query(A).all(): session.delete(a) for b in session.query(B).all(): session.delete(b) for op in session.query(models.Operation).all(): session.delete(op) session.commit()
def teardown(): session = Session() # map(session.delete, session.query(A)) for a in session.query(A).all(): session.delete(a) for b in session.query(B).all(): session.delete(b) for op in session.query(models.Operation).all(): session.delete(op) for ver in session.query(models.Version).all(): session.delete(ver) session.commit()
def teardown(): session = Session() As = session.query(A).all() Bs = session.query(B).all() Ops = session.query(models.Operation).all() for a in As: session.delete(a) # map(session.delete, As) # for some reason mapping session.delete does not execute for b in Bs: session.delete(b) # map(session.delete, Bs) # for some reason mapping session.delete does not execute for op in Ops: session.delete(op) # map(session.delete, Ops) # for some reason mapping session.delete does not execute session.commit()
def addstuff(): a1 = A(name="first a") a2 = A(name="second a") b1 = B(name="first b", a=a1) b2 = B(name="second b", a=a1) b3 = B(name="third b", a=a2) session = Session() session.add_all([a1, a2, b1, b2, b3]) version = models.Version() version.created = datetime.datetime.now() session.add(version) session.flush() version_id = version.version_id session.commit() session = Session() for op in session.query(models.Operation): op.version_id = version_id session.commit()