def __addData(self, input_dic, cursor): field_info_dic = self.getFieldInfo(input_dic["data_info_key"]) if not field_info_dic: return "Failed to getFieldInfo(): key [%s]"%input_dic["data_info_key"] total_keys = field_info_dic["select"] # 입력 데이터 제작 set_dic = dict() for i in range(len(total_keys)): key = total_keys[i] if key in input_dic: set_dic[key] = input_dic[key] for key in field_info_dic["essential"]: if key not in set_dic: return "Failed to addUpdateData : essential field [%s] data is missing"%key return dao.insertData(cursor, "%s Data"%(field_info_dic["table"]), field_info_dic["table"], set_dic)
def __addUpdateData(self, input_dic, cursor): field_info_dic = self.getFieldInfo(input_dic["data_info_key"]) if not field_info_dic: return "Failed to getFieldInfo(): key [%s]"%input_dic["data_info_key"] total_keys = field_info_dic["select"] where_dic = dict() # 데이터 존재 여부 확인용 LOAD loaded_data = None for key in field_info_dic["unique"]: if key in input_dic: if input_dic[key]: where_dic[key] = input_dic[key] loaded_data = self.getDataList(input_dic) if loaded_data: loaded_data = loaded_data[0] break # 입력 데이터 제작 set_dic = dict() for i in range(len(total_keys)): key = total_keys[i] if key in input_dic: set_dic[key] = str(input_dic[key]).strip() else: if loaded_data: # 미지정값은 기존 값으로 할당 if loaded_data[i]: set_dic[key] = loaded_data[i] for key in field_info_dic["essential"]: if key not in set_dic: return "Failed to addUpdateData : essential field [%s] data is missing"%key if where_dic: if loaded_data: ret = dao.updateData(cursor, "%s Data"%(field_info_dic["table"]), field_info_dic["table"], set_dic, where_dic) else: ret = dao.insertData(cursor, "%s Data"%(field_info_dic["table"]), field_info_dic["table"], set_dic) return ret else: return "Failed to addUpdateData : %s"%(field_info_dic["table"])