码迷,mamicode.com
首页 > 其他好文 > 详细

test

时间:2018-07-24 17:50:43      阅读:162      评论:0      收藏:0      [点我收藏+]

标签: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)
View Code

 

这是测试3

1233333333333333

这是测试4

1233333333333333

这是测试5

1233333333333333

这是测试6

1233333333333333

test

标签:one   show   must   data   append   load   illegal   sig   count   

原文地址:https://www.cnblogs.com/fmgao-technology/p/9360528.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!