writefile= open ("E:\\program\\pycharm\\fee_level_modify\\test.txt", 'w'); with open("C:\\Users\\ea\\Documents\\order.txt", 'r') as textfile: lines = textfile.readlines() for line in lines: line = line.strip('\n') index = line.find(' ') src_order = line[0:index] index_1 = src_order.find(':') dst_order = line[index+1:] index_2 = dst_order.find(':') src_order_id = src_order[index_1 + 1:] dst_order_id = dst_order[index_2 + 1:] writefile.write("insert into order_db.t_order_card (Forder_id,Forder_type,Ftotal_amount,Forder_state,Fuid,Fsku_id,Fproduct_name,Fbank_type,Fbank_branch,Fcheck_name,Fcard_no,Fcard_no_ecp,Fpay_time,Fpay_state,Faccount_time,Fret_msg,Fcreate_time,Fmodify_time) select '%s',Forder_type,Ftotal_amount,Forder_state,Fuid,Fsku_id,Fproduct_name,Fbank_type,Fbank_branch,Fcheck_name,Fcard_no,Fcard_no_ecp,Fpay_time,Fpay_state,Faccount_time,Fret_msg,now(),now() from order_db.t_order_card where Forder_id = '%s';\n" % (dst_order_id, src_order_id)) writefile.close()
从txt文件中获取字段批量生成sql语句
最新推荐文章于 2021-04-16 15:34:10 发布