def setUp(self): super(DBFixture, self).setUp() print get_engine() self.dbfixture = SQLAlchemyFixture( engine=get_engine(), env={'InOutData': InOutReason}) self.data = self.dbfixture.data(InOutData) self.data.setup() self.addCleanup(self.data.teardown)
def setUp(self): super(DBFixture, self).setUp() self.dbfixture = SQLAlchemyFixture( engine=get_engine(), env={'AssetConsumeInfoData': AssetConsumeInfoModel}) self.data = self.dbfixture.data(AssetConsumeInfoData) BASE.metadata.create_all(get_engine()) self.data.setup() self.addCleanup(self.data.teardown)
def setUp(self): super(DBFixture, self).setUp() print get_engine() self.dbfixture = SQLAlchemyFixture( engine=get_engine(), env={'AssetTypeData': AssetTypeModel}) self.data = self.dbfixture.data(AssetTypeData) self.data.setup() self.addCleanup(self.data.teardown)
def setUp(self): super(DBFixture, self).setUp() self.dbfixture = SQLAlchemyFixture( engine=get_engine(), env={'DeviceStateData': DeviceState}) self.data = self.dbfixture.data(DeviceStateData) BASE.metadata.create_all(get_engine()) self.data.setup() self.addCleanup(self.data.teardown)
def add_batch_asset_infos(self, datas): print datas try: engine = get_engine() connection = engine.connect() trans = connection.begin() # 得到tb_asset_info这个表 aim = table( "tb_asset_info", column("asset_id"), column("asset_type_id"), column("model_id"), column("device_state_id"), column("user_name"), column("store_place_id"), column("remark"), column("in_out_reason_id"), column("sn"), column("store_state_id"), column("up_time"), column("create_time"), column("update_time"), column("type_info"), ) ins = aim.insert() connection.execute(ins, datas) trans.commit() except Exception, _ex: msg = "add_batch_asset_infos error: %s" % str(_ex) LOG.error(msg) return False, u'批量添加数据失败!'
def setUp(self): super(DBFixture, self).setUp() self.dbfixture = SQLAlchemyFixture( engine=get_engine(), env={'MpProviderData': Provider}) self.data = self.dbfixture.data(MpProviderData) self.data.setup() self.addCleanup(self.data.teardown)