def save(self, configs): # ret = db.select("config").list() # for config in ret: # c = configs.get(config.code) # if c: # db.delete('config', where="configId=$configId", vars=config) for key, val in configs.items(): db.delete('config', where="code=$code", vars={"code":key}) db.insert("config", **{'code':key, 'val':val})
def saveImgHead(self, imgHead): headNum = imgHead.get("headNum") if headNum: imgHeadDb = self.getByHeadNum(headNum) if imgHeadDb: headId = imgHeadDb.get("headId") db.update("imgHead", where="headId=$headId", vars={'headId':headId}, **imgHead) else: db.insert("imgHead", **imgHead)
def saveOrUpdateOcrResult(self, ocrResult): results = None if ocrResult and ocrResult.get('lineId') and ocrResult.get('ocrType'): results = db.select('ocrResult', where="lineId=$lineId and ocrType=$ocrType", vars={'lineId':ocrResult.get('lineId'), 'ocrType':ocrResult.get('ocrType')}).list() else: return None if results and len(results) > 0: ocrResult['resultId'] = results[0].get('resultId') self.update(ocrResult) else: db.insert("ocrResult", **ocrResult)
def create_account(user_info): spassword = create_password(user_info.password) s = app.helpers.session.get_session() if 'is_active' in user_info: user_info.is_active = '1' else: user_info.is_active = '0' last_insert_rowid = db.insert('users', email=user_info.email, name=user_info.name, password=spassword, creator=s.userid, created=int(time.time()), comments=user_info.comments, is_active=user_info.is_active) last_user = get_user_by_id(last_insert_rowid) # initiate dictionary records = {} # se last_insert_rowid == True, assume que usuario foi criado com sucesso if last_insert_rowid: # set response message to OK records['Result'] = 'OK' records['Record'] = last_user else: records['Result'] = 'ERROR' records['Message'] = 'USUÁRIO NÃO CRIADO!' return json.dumps(records)
def saveOrUpdate(self, uploadTask): uploadTaskDb = None if uploadTask and uploadTask.headId: uploadTaskDb = self.getByHeadId(uploadTask.headId) if uploadTaskDb: uploadTask['uploadTaskId'] = uploadTaskDb.uploadTaskId db.update("uploadTask", where="uploadTaskId=$uploadTaskId", vars={'uploadTaskId':uploadTaskDb.uploadTaskId}, **uploadTask) else: return self.getById(db.insert("uploadTask", **uploadTask))
def saveAll(self, headId, imgLines): lineIds = [] dbImgLines = db.select('imgLine', where="headId=$headId", vars={"headId":headId}) for imgLine in dbImgLines: lineIds.append(imgLine.get("lineId")) imgOrd = self.getMaxOrd(headId) ret = [] for imgLine in imgLines: if imgLine.get("lineId") in lineIds: db.update('imgLine', where="lineId=$lineId", vars={'lineId':imgLine.get("lineId")}, **imgLine) ret.append(self.getByLineId(imgLine.get("lineId"))) else: imgOrd += 1 imgLine['imgOrd'] = imgOrd imgLine["headId"] = headId lineId = db.insert('imgLine', **imgLine) ret.append(self.getByLineId(lineId)) return ret
def saveHeadAndLine(self, imgHead): from imgLineDao import ImgLineDao imgLineDao = ImgLineDao() allLines = [] imgLines = imgHead.get("imgLines") # 头表 if imgLines or imgLines is not None and len(imgLines) == 0: del imgHead["imgLines"] headId = imgHead.get('headId') if headId: db.update('imgHead', where="headId=$headId", vars={'headId':headId}, **imgHead) else: headId = db.insert('imgHead', **imgHead) # 行表 if imgLines is None or len(imgLines) == 0: return None dbLines = imgLineDao.saveAll(headId, imgLines) allLines.extend(dbLines) self.updateHeadSizeAndQty(headId) return allLines
def save(self, uploadTask): return self.getById(db.insert("uploadTask", **uploadTask))
def create_classes(is_active, name, creator): db.insert("tickets_class", is_active=is_active, name=name, creator=creator)
def saveOcrResult(self, ocrResult): return db.insert("ocrResult", **ocrResult)
def create_caterogies(self, **wk): db.insert()
def save(self, uploadTaskLog): db.insert("uploadTaskLog", **uploadTaskLog)