当前位置: 首页>>代码示例>>Python>>正文


Python Session.commit方法代码示例

本文整理汇总了Python中tests.run.Session.commit方法的典型用法代码示例。如果您正苦于以下问题:Python Session.commit方法的具体用法?Python Session.commit怎么用?Python Session.commit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tests.run.Session的用法示例。


在下文中一共展示了Session.commit方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setUpClass

# 需要导入模块: from tests.run import Session [as 别名]
# 或者: from tests.run.Session import commit [as 别名]
    def setUpClass(cls):

        session = Session()

        cls.u1 = TrUser(login="11111", type="phone", auth_code="1111", authenticated=True)
        cls.u2 = TrUser(login="22222", type="phone", auth_code="2222", authenticated=True)
        cls.u3 = TrUser(login="33333", type="phone", auth_code="3333", authenticated=True)

        user_list = [cls.u1, cls.u2, cls.u3]
        cls.user_count = len(user_list)
        session.add_all(user_list)
        session.flush()
        session.refresh(cls.u1)
        session.refresh(cls.u2)
        session.commit()

        cls.p1 = TrPlace(title="Title1", latitude=54.123, longitude=35.123, type="Restaurant", user_id=cls.u1.id)
        cls.p2 = TrPlace(title="Title2", latitude=54.123, longitude=35.123, type="Parking", user_id=cls.u2.id)
        cls.p3 = TrPlace(title=u'Заголовок3', latitude=54.123, longitude=35.123, type="Caffe", user_id=cls.u2.id)

        p_list = [cls.p1, cls.p2, cls.p3]
        cls.p_count = len(p_list)
        session.add_all(p_list)
        session.commit()

        session.close()
开发者ID:toxxin,项目名称:TrackerRestApi,代码行数:28,代码来源:place.py

示例2: tearDownClass

# 需要导入模块: from tests.run import Session [as 别名]
# 或者: from tests.run.Session import commit [as 别名]
    def tearDownClass(cls):

        session = Session()

        users = session.query(TrUser).all()
        for user in users:
            session.delete(user)
        session.commit()

        session.close()
开发者ID:toxxin,项目名称:TrackerRestApi,代码行数:12,代码来源:location.py

示例3: setUpClass

# 需要导入模块: from tests.run import Session [as 别名]
# 或者: from tests.run.Session import commit [as 别名]
    def setUpClass(cls):

        session = Session()

        cls.u1 = TrUser(login="11111", type="phone", auth_code="1111", authenticated=True)
        session.add(cls.u1)
        session.flush()
        session.refresh(cls.u1)
        session.commit()

        session.close()
开发者ID:toxxin,项目名称:TrackerRestApi,代码行数:13,代码来源:vehicle.py

示例4: tearDownClass

# 需要导入模块: from tests.run import Session [as 别名]
# 或者: from tests.run.Session import commit [as 别名]
    def tearDownClass(cls):

        session = Session()

        users = session.query(TrUser).all()
        map(session.delete, users)

        groups = session.query(TrGroup).all()
        map(session.delete, groups)

        session.commit()

        session.close()
开发者ID:toxxin,项目名称:TrackerRestApi,代码行数:15,代码来源:group.py

示例5: tearDownClass

# 需要导入模块: from tests.run import Session [as 别名]
# 或者: from tests.run.Session import commit [as 别名]
    def tearDownClass(cls):

        session = Session()

        users = session.query(TrUser).all()
        map(session.delete, users)

        places = session.query(TrPlace).all()
        map(session.delete, places)

        session.commit()

        session.close()
开发者ID:toxxin,项目名称:TrackerRestApi,代码行数:15,代码来源:place.py

示例6: setUpClass

# 需要导入模块: from tests.run import Session [as 别名]
# 或者: from tests.run.Session import commit [as 别名]
    def setUpClass(cls):

        session = Session()

        cls.u1 = TrUser("2013-12-12 12:12:12", "u1", "testtest")
        user_list = [cls.u1]
        cls.user_count = len(user_list)
        session.add_all(user_list)
        session.flush()
        session.refresh(cls.u1)
        session.commit()

        session.close()
开发者ID:toxxin,项目名称:TrackerRestApi,代码行数:15,代码来源:push.py

示例7: setUpClass

# 需要导入模块: from tests.run import Session [as 别名]
# 或者: from tests.run.Session import commit [as 别名]
    def setUpClass(cls):

        session = Session()

        cls.u1 = TrUser("2013-12-12 12:12:12", "u1", "testtest")
        user_list = [cls.u1]
        cls.user_count = len(user_list)
        session.add_all(user_list)
        session.flush()
        session.refresh(cls.u1)
        session.commit()

        cls.v1 = TrVehicle("v1", cls.u1.ID, car_model_id=111)
        cls.v2 = TrVehicle("v2", cls.u1.ID, car_model_id=222)
        v_list = [cls.v1, cls.v2]
        cls.v_count = len(v_list)
        session.add_all(v_list)
        session.commit()

        session.close()
开发者ID:toxxin,项目名称:TrackerRestApi,代码行数:22,代码来源:help.py

示例8: setUpClass

# 需要导入模块: from tests.run import Session [as 别名]
# 或者: from tests.run.Session import commit [as 别名]
    def setUpClass(cls):

        session = Session()

        cls.u1 = TrUser(login="11111", type="phone", auth_code="1111", authenticated=True)
        cls.u2 = TrUser(login="22222", type="phone", auth_code="2222", authenticated=True)
        cls.u3 = TrUser(login="33333", type="phone", auth_code="3333", authenticated=True)
        u_list = [cls.u1, cls.u2, cls.u3]
        cls.user_count = len(u_list)
        session.add_all(u_list)
        session.flush()
        session.refresh(cls.u1)
        session.refresh(cls.u2)
        session.commit()

        cls.v1 = TrVehicle("v1", cls.u1.id, car_model_id=111, year=1991)
        cls.v2 = TrVehicle("v2", cls.u2.id, car_model_id=111, year=1991)
        cls.v3 = TrVehicle("v3", cls.u2.id, car_model_id=111, year=1991)
        v_list = [cls.v1, cls.v2, cls.v3]
        cls.v_count = len(v_list)
        session.add_all(v_list)
        session.commit()

        cls.d1 = TrDevice(sn='EW-14100001-UT', imei_number='1234', accel_stat=True, time_interval=1, phone1="+79260000001", vehicle_id=cls.v1.id)
        cls.d2 = TrDevice(sn='EW-14100002-UT', imei_number='5678', accel_stat=True, time_interval=2, phone1="+79260000002", vehicle_id=cls.v2.id)
        cls.d3 = TrDevice(sn='EW-14100003-UT', imei_number='9012', accel_stat=True, time_interval=3, phone1="+79260000003", vehicle_id=None)
        cls.d4 = TrDevice(sn='EW-14100004-UT', imei_number='3456', accel_stat=True, time_interval=4, phone1="+79260000003", vehicle_id=None)
        d_list = [cls.d1, cls.d2, cls.d3, cls.d4]
        cls.device_count = len(d_list)
        session.add_all(d_list)
        session.commit()

        session.close()
开发者ID:toxxin,项目名称:TrackerRestApi,代码行数:35,代码来源:device.py

示例9: setUpClass

# 需要导入模块: from tests.run import Session [as 别名]
# 或者: from tests.run.Session import commit [as 别名]
    def setUpClass(cls):

        session = Session()

        cls.u1 = TrUser("2013-12-12 12:12:12", "u1", "testtest")
        user_list = [cls.u1]
        cls.user_count = len(user_list)
        session.add_all(user_list)
        session.flush()
        session.refresh(cls.u1)
        session.commit()

        cls.d1 = TrDevice("d1", cls.u1.ID)
        cls.d2 = TrDevice("d2", cls.u1.ID)
        cls.d3 = TrDevice("d3", cls.u1.ID)
        device_list = [cls.d1, cls.d2, cls.d3]
        cls.device_count = len(device_list)
        session.add_all(device_list)
        session.commit()

        cls.l1 = TrDLocation("55.123,54.332", "2013-12-12 12:12:12", cls.d1.device_ID)
        cls.l2 = TrDLocation("33.123,33.332", "2013-12-12 11:11:11", cls.d2.device_ID)
        cls.l3 = TrDLocation("44.123,44.332", "2013-10-10 10:10:10", cls.d2.device_ID)
        location_list = [cls.l1, cls.l2, cls.l3]
        cls.location_count = len(location_list)
        session.add_all(device_list)
        session.commit()

        session.close()
开发者ID:toxxin,项目名称:TrackerRestApi,代码行数:31,代码来源:location.py

示例10: setUpClass

# 需要导入模块: from tests.run import Session [as 别名]
# 或者: from tests.run.Session import commit [as 别名]
    def setUpClass(cls):

        session = Session()

        cls.u1 = TrUser("2013-12-12 12:12:12", "u1", "testtest")
        cls.u2 = TrUser("2013-12-12 12:12:12", "u2", "testtest1")
        user_list = [cls.u1, cls.u2]
        cls.user_count = len(user_list)
        session.add_all(user_list)
        session.flush()
        session.refresh(cls.u1)
        session.refresh(cls.u2)
        session.commit()

        cls.d1 = TrDevice("d1", cls.u1.ID)
        cls.d2 = TrDevice("d2", cls.u2.ID)
        device_list = [cls.d1, cls.d2]
        cls.device_count = len(device_list)
        session.add_all(device_list)
        session.commit()

        cls.g1 = TrDGeozone("g1", cls.d1.device_ID)
        cls.g2 = TrDGeozone("g2", cls.d2.device_ID)
        geo_list = [cls.g1, cls.g2]
        cls.geo_count = len(geo_list)
        session.add_all(geo_list)
        session.commit()

        session.close()
开发者ID:toxxin,项目名称:TrackerRestApi,代码行数:31,代码来源:geo.py

示例11: setUpClass

# 需要导入模块: from tests.run import Session [as 别名]
# 或者: from tests.run.Session import commit [as 别名]
    def setUpClass(cls):

        session = Session()

        cls.u1 = TrUser(login="11111", type="phone", auth_code="1111", authenticated=True)
        cls.u2 = TrUser(login="22222", type="phone", auth_code="2222", authenticated=True)
        cls.u3 = TrUser(login="33333", type="phone", auth_code="3333", authenticated=True)
        cls.u4 = TrUser(login="44444", type="phone", auth_code="4444", authenticated=True)
        u_list = [cls.u1, cls.u2, cls.u3, cls.u4]
        cls.user_count = len(u_list)
        session.add_all(u_list)
        session.flush()
        session.refresh(cls.u1)
        session.refresh(cls.u2)
        session.refresh(cls.u3)
        session.refresh(cls.u4)
        session.commit()

        cls.g1 = TrGroup(user_id=cls.u1.id, title="g1")
        cls.g2 = TrGroup(user_id=cls.u1.id, title="g2")
        g_list = [cls.g1, cls.g2]
        cls.group_count = len(g_list)
        session.add_all(g_list)
        session.commit()

        # Add users to groups
        cls.g1.users.append(cls.u3)
        cls.g1.users.append(cls.u4)
        session.add(cls.g1)
        session.commit()

        session.close()
开发者ID:toxxin,项目名称:TrackerRestApi,代码行数:34,代码来源:group.py


注:本文中的tests.run.Session.commit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。