def save_data(self, url): id = genUUID() name = genUUID() + ".jpg" dic = dict() dic['filename'] = name dic['min_path'] = url dic['normal_path'] = url dic['origin_filename'] = name dic['valid'] = 1 dis = "" for key in dic: dis += key dis += "='" dis += str(dic[key]) dis += "'," dis = dis[0:len(dis) - 1] mysql = MysqlHelper(Configs()) sql = "insert into " sql += tableName sql += " set id=%s," sql += dis mysql.save(sql, id) return id
def gensto(self, dao, list): status = False count = len(list) element = 0 if count > 0: for item in list: try: id = genUUID() dao.save_or_update(item, id) element += 1 except Exception as e: import traceback msg = traceback.format_exc() # print(msg) LogGo.warning(repr(e)) LogGo.info('Total :' + str(count) + ' / ' + str(element) + ' elements Saved!') if element == 0: status = False else: status = True else: LogGo.info("0 Element!") stauts = False return status
def store_count(self, list): status = False count = len(list) element = 0 update = 0 if count > 0: for program in list: try: if self.check_for_exists(program) == 1: update += 1 else: id = genUUID() self.pc.save(program, id) element += 1 except Exception as e: import traceback msg = traceback.format_exc() LogGo.warning(msg) LogGo.info('Total :' + str(count) + ' (' + str(element) + ' Saved, ' + str(update) + ' Updated)') if element == 0 and update == 0: status = False else: status = True else: LogGo.info("0 Element!") # return False return status
def save_data(group_id, picture_id): id = genUUID() dic = dict() dic['group_id'] = group_id dic['picture_id'] = picture_id dis = "" for key in dic: dis += key dis += "='" dis += str(dic[key]) dis += "'," dis = dis[0:len(dis) - 1] mysql = MysqlHelper(Configs()) sql = "insert into " sql += tableName sql += " set id=%s," sql += dis mysql.save(sql, id) return id
def store(self, news_list: [], article_list: [], heavy_list: [] = None): status = False if len(article_list) != len(news_list): LogGo.error("news count unmatch article count") return False count = len(news_list) element = 0 if count > 0: if heavy_list is not None: for news, article, heavy in zip(news_list, article_list, heavy_list): try: id = genUUID() self.news.save(news, id) self.article.save(article, id) self.heavy.save_with_news_id(heavy, id) element += 1 except Exception as e: LogGo.warning(repr(e)) else: for news, article in zip(news_list, article_list): try: id = genUUID() self.news.save(news, id) self.article.save(article, id) element += 1 except Exception as e: LogGo.warning(repr(e)) LogGo.info('Total :' + str(count) + ' / ' + str(element) + ' elements Saved!') if element == 0: status = False else: status = True # return True else: LogGo.info("0 Element!") # return False return status
def save_by_type_title(self, type_id, title): dic = { self.TB.title.key: title, self.TB.valid.key: '1', self.TB.dic_type_id.key: type_id } id = genUUID() if self.save(dic, id): return id
def save_group_data(list): if len(list) < 1: return None dao = PictureDao() group_id = genUUID() ids = [] for pic in list: ids.append(dao.save_data(pic)) for pic_id in ids: GroupPictureDao.save_data(group_id, pic_id) return group_id
def store_soap(self, soap): status = False if len(soap) < 1: LogGo.info("no data to save!") return False try: id = genUUID() self.soap.save(soap, id) status = True except Exception as e: import traceback msg = traceback.format_exc() LogGo.warning(msg) LogGo.info('Soap Saved') return status
def save_data_insert(dic): id = genUUID() mysql = MysqlHelper(Configs()) _sql = "INSERT INTO news(`id`, " _val = " VALUES (%s," _par = [ id, ] for key in dic: _sql += "`" _sql += key _sql += "`," if type(dic[key]) == type(str): _val += "%s," elif type(dic[key]) == type(int): _val += "%i," else: _val += "%s," _par.append(dic[key]) _sql = _sql[0:len(_sql) - 1] _sql += ")" _val = _val[0:len(_val) - 1] _val += ")" _sql += _val mysql.save(_sql, _par) sql = "insert into " sql += article_table_name sql += " set id=%s" mysql.save(sql, id)
def save_data(dic): dis = "" id = genUUID() for key in dic: dis += key dis += "='" dis += str(dic[key]) dis += "'," dis = dis[0:len(dis) - 1] mysql = MysqlHelper(Configs()) sql = "insert into news set id=%s," sql += dis mysql.save(sql, id) sql = "insert into " sql += article_table_name sql += " set id=%s" mysql.save(sql, id)
def save_by_program_type(self, program_id, type_id): dic = {self.TB.programId.key: program_id, self.TB.typeId.key: type_id} id = genUUID() if self.save(dic, id): return id