标签:one show must data append load illegal sig count
1233333333333333
def upd_sql(self):
print(self.sql)
ta_dql = self.sql.find("staff_table")
se_dql = self.sql.find("SET")
w_dql = self.sql.find("WHERE")
e_dql = self.sql.find("=")
e_cou = self.sql.count("=")
if ta_dql <= -1:
print("need keyword 【staff_table】 ")
elif se_dql <= -1:
print("need keyword 【SET】 ")
elif w_dql <= -1:
print("need keyword 【WHERE】 ")
elif e_dql <= -1:
print("need keyword 【=】 ")
elif e_cou != 2:
print(‘need 【2个】 keyword 【=】 ‘)
else:
assignment_content = self.sql[se_dql + len("SET"):w_dql].strip().replace("\"", "")
assignment_wd = assignment_content.split("=")[0].strip()
condition_content = self.sql[w_dql + len("WHERE"):].strip().replace("\"", "")
condition_wd = condition_content.split("=")[0].strip()
if assignment_wd not in self.li_cols:
print("""
assignment column is illegal word, must in:
【name, age, phone, department, fire_date】
""")
elif condition_wd not in self.li_cols:
print("""
condition column is illegal word, must in:
【name, age, phone, department, fire_date】
""")
else:
assignment_val = assignment_content.split("=")[1].strip()
condition_val = condition_content.split("=")[1].strip()
res_assigs = self.load_data().res["staff_table"][assignment_wd]
# assignment_val row num list
li_assig = []
try:
for index, i in enumerate(res_assigs):
if i == condition_val:
li_assig.append(index)
except ValueError:
print("assignment val is not defined")
# assignment_val col num
for index, i in enumerate(self.li_cols):
if assignment_wd == i:
assig_col_num = index + 1
upd_dic = {"li_assig": li_assig, "assig_col_num": assig_col_num, "assignment_val": assignment_val}
print(upd_dic)
if len(li_assig) == 0:
print("condition val is not defined")
else:
self.upd_data(upd_dic)
1233333333333333
def upd_sql(self): print(self.sql) ta_dql = self.sql.find("staff_table") se_dql = self.sql.find("SET") w_dql = self.sql.find("WHERE") e_dql = self.sql.find("=") e_cou = self.sql.count("=") if ta_dql <= -1: print("need keyword 【staff_table】 ") elif se_dql <= -1: print("need keyword 【SET】 ") elif w_dql <= -1: print("need keyword 【WHERE】 ") elif e_dql <= -1: print("need keyword 【=】 ") elif e_cou != 2: print(‘need 【2个】 keyword 【=】 ‘) else: assignment_content = self.sql[se_dql + len("SET"):w_dql].strip().replace("\"", "") assignment_wd = assignment_content.split("=")[0].strip() condition_content = self.sql[w_dql + len("WHERE"):].strip().replace("\"", "") condition_wd = condition_content.split("=")[0].strip() if assignment_wd not in self.li_cols: print(""" assignment column is illegal word, must in: 【name, age, phone, department, fire_date】 """) elif condition_wd not in self.li_cols: print(""" condition column is illegal word, must in: 【name, age, phone, department, fire_date】 """) else: assignment_val = assignment_content.split("=")[1].strip() condition_val = condition_content.split("=")[1].strip() res_assigs = self.load_data().res["staff_table"][assignment_wd] # assignment_val row num list li_assig = [] try: for index, i in enumerate(res_assigs): if i == condition_val: li_assig.append(index) except ValueError: print("assignment val is not defined") # assignment_val col num for index, i in enumerate(self.li_cols): if assignment_wd == i: assig_col_num = index + 1 upd_dic = {"li_assig": li_assig, "assig_col_num": assig_col_num, "assignment_val": assignment_val} print(upd_dic) if len(li_assig) == 0: print("condition val is not defined") else: self.upd_data(upd_dic)
1233333333333333
1233333333333333
1233333333333333
1233333333333333
标签:one show must data append load illegal sig count
原文地址:https://www.cnblogs.com/fmgao-technology/p/9360528.html