コード例 #1
0
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()
コード例 #2
0
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()
コード例 #3
0
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()
コード例 #4
0
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()
コード例 #5
0
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()
コード例 #6
0
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()
コード例 #7
0
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()
コード例 #8
0
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()
コード例 #9
0
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()