2019-11-12 SQL-批量插入语句

-- coding: utf-8 --

sqls = ''
number = 7
areas = ['nanhu', 'xiuzhou', 'jiashan', 'haiyan', 'haining', 'tongxiang', 'pinghu']
areas_chinese = ['南湖区', '秀洲区', '嘉善县', '海盐县', '海宁市', '桐乡市', '平湖市']
data_node_name_quarter = ['"最多跑一次"实现率', '"最多跑一次"满意率', '对欧等发达经济体招商项目数', '对欧等发达经济体招商总额']
data_node_name_month = ['重大产业项目签约数', '']
for data_node_name in data_node_name_quarter:
for i in range(0, number):
for year in range(2016, 2021):
for quarter in range(1,5):
sql = "INSERT INTO res_jx_data_node_quarter_" + areas[i] +
" (C_YEAR, C_QUARTER, C_AREA_NAME, C_DATA_NODE_NAME, C_PX) VALUES" +
" (" + str(year) + ", " + str(quarter) + ", '" + areas_chinese[i] + "', '" +
data_node_name + "', 1)" + "';\n"
sqls = sqls + sql
for data_node_name in data_node_name_month:
for i in range(0, number):
for year in range(2016, 2021):
for month in range(1,13):
sql = "INSERT INTO res_jx_data_node_month_" + areas[i] +
" (C_YEAR, C_MONTH, C_AREA_NAME, C_DATA_NODE_NAME, C_PX) VALUES" +
" (" + str(year) + ", " + str(month) + ", '" + areas_chinese[i] + "', '" +
data_node_name + "', 1)" + "';\n"
sqls = sqls + sql
print(sqls)

你可能感兴趣的:(2019-11-12 SQL-批量插入语句)