python批量生成SQL语句
发布时间:2020-12-20 10:00:57 所属栏目:Python 来源:网络整理
导读:1,首先写一条能运行成功插入SQL的语句 INSERT INTO sign_guest(realname,phone,email,sign,event_id)VALUES("jack",13800101100,"jack@mail.com",1) 2,通过python批量写如文本 f =open( ' guest.txt ' , w ' ) for i in range(1,100 ): str_i = str(i) rea
1,首先写一条能运行成功插入SQL的语句 INSERT INTO sign_guest(realname,phone,email,sign,event_id)VALUES("jack",13800101100,"jack@mail.com",1) 2,通过python批量写如文本 f =open('guest.txt',w') for i in range(1,100): str_i = str(i) realname = jack' + str_i phone = 1380090911 + i email = "" + str_i + @mail.com" sql = INSERT INTO sign_guest(realname,event_id) values ("'+realname+",'+str(phone)+,"'+email+ f.write(sql) f.write(n) f.close() 3,将生成的语句粘贴到mysql客户端执行 ? ?4,按照此思路可以进行其他语句的批量执行。 ? (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |