python数据库操作批量sql执行_利用Python脚本批量生成SQL语句

通过Python脚本批量生成插入数据的SQL语句

原始SQL语句:

INSERT INTO system_user (id, login_name, name, password, salt, code, createtime, email, main_org, positions, status, used, url, invalid, millis, id_card, phone_no, past, end_date, start_date)

VALUES ('6', 'db', 'db', '53dd4e491d16f21b19606e8fb0619522e6d5f307', 'a211f9dd3120178a', NULL, sysdate, '[email protected]', NULL, '', 'enabled', 'Used', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);

CreateSQL.py

f = open("/Users/apple/Downloads/sql/insertUser.sql",'w')

for i in range(6,57):

str_i = str(i)

login_name = "test"+str_i

name = "test"+str_i

sql = 'INSERT INTO system_user (id, login_name, name, password, salt, code, createtime, email, main_org, positions, status, used, url, invalid, millis, id_card, phone_no, past, end_date

你可能感兴趣的:(python数据库操作批量sql执行_利用Python脚本批量生成SQL语句)