40 KiB
40 KiB
In [ ]:
import json
filename = 'data/羊庙测试人员信息.json'
with open(filename,'r') as fl:
dict1 = json.load(fl)
dict2 = {}
for k,v in dict1.items():
for item in v:
bh = item['avatar_id']
del item['avatar_id']
dict2[bh] = item
filename = 'data/羊庙人员名单.json'
with open(filename, 'w') as fl:
json.dump(dict2, fl, ensure_ascii=False,default=str)
print('ok')In [ ]:
import json
import time
import csv
filename = '../item.json'
item = {}
unit = {}
with open(filename,'r') as fl:
dict1 = json.load(fl)
for k,v in dict1.items():
item[k] = v
re_ta = {}
dict1 = {}
list1 = []
#print("\n运动项目信息:")
filename = 'data/140.csv'
with open(filename,'r',newline='') as csv_file:
fl = csv.reader(csv_file,delimiter=',')
header = next(fl)
for line in fl:
#line = re.sub('[\r\n\f ]{1,}', '', line)
list1.append(line)
list2 = []
for result in list1:
user = int(result[2])
if user not in list2:
list2.append(user)
list2.sort()
print(len(list2))
print(list2)In [ ]:
import openpyxl
import json
import time
wb = openpyxl.load_workbook('data/杨庙运动风险筛查统计表.xlsx')
sheet = wb.active
person = {}
for n in range(2, sheet.max_row+1):
code = int(sheet.cell(n, 1).value)
person.setdefault(code, {})
dict1 = {}
if sheet.cell(n, 8).value is not None:
name = sheet.cell(n, 8).value
else:
name ='不详'
dict1['name'] = name
if sheet.cell(n, 9).value is not None:
dict1['birth'] = str(sheet.cell(n, 9).value).split(' ')[0]
if sheet.cell(n, 10).value is not None:
dict1['phone'] = str(sheet.cell(n, 10).value)
if sheet.cell(n,11).value is not None:
dict1['id_num'] = sheet.cell(n,11).value
person[code] = dict1
print(len(person))
filename = 'data/杨庙运动风险筛查统计表信息.json'
with open(filename, 'w') as fl:
json.dump(person, fl, ensure_ascii=False,default=str)
print('ok')In [ ]:
import openpyxl
import json
import time
wb = openpyxl.load_workbook('data/羊庙恢复版.xlsx')
sheet = wb.active
person = {}
for n in range(2, sheet.max_row+1):
if sheet.cell(n, 4).value is not None:
code = int(sheet.cell(n, 4).value)
person.setdefault(code, {})
dict1 = {}
name = sheet.cell(n, 5).value
dict1['name'] = name
dict1['bh'] = n - 1
dict1['sex'] = sheet.cell(n, 6).value
if sheet.cell(n, 9).value is not None:
dict1['phone'] = str(sheet.cell(n, 9).value)
if sheet.cell(n,8).value is not None:
dict1['id_num'] = sheet.cell(n,8).value
if sheet.cell(n,3).value is not None:
dict1['unit'] = sheet.cell(n,3).value
person[code] = dict1
print(len(person))
filename = 'data/杨庙恢复版信息.json'
with open(filename, 'w') as fl:
json.dump(person, fl, ensure_ascii=False,default=str)
print('ok')In [ ]:
re_ta = {}
dict1 = {}
list1 = []
#print("\n运动项目信息:")
filename = 'data/140.csv'
with open(filename,'r',newline='') as csv_file:
fl = csv.reader(csv_file,delimiter=',')
header = next(fl)
for line in fl:
#line = re.sub('[\r\n\f ]{1,}', '', line)
list1.append(line)
list2 = []
for result in list1:
user = int(result[2])
if user not in list2:
list2.append(user)
list2.sort()
set1 = set()
filename = 'data/杨庙恢复版信息.json'
with open(filename,'r') as fl:
dict_base = json.load(fl)
for k, v in dict_base.items():
set1.add(int(k))
filename = 'data/杨庙运动风险筛查统计表信息.json'
with open(filename,'r') as fl:
dict1 = json.load(fl)
list_fx = []
for k,v in dict1.items():
if int(k) in list2 and k not in dict_base.keys() and v['name'] != '不详':
set1.add(int(k))
#print(len(list_fx))
#print(len(set1))
for item in list2:
if item not in set1:
print(item)In [ ]:
filename = 'data/杨庙恢复版信息.json'
with open(filename,'r') as fl:
dict_base = json.load(fl)
for k, v in dict_base.items():
set1.add(int(k))
filename = 'data/杨庙运动风险筛查统计表信息.json'
with open(filename,'r') as fl:
dict1 = json.load(fl)
for k,v in dict_base.items():
if k in dict1.keys() and 'phone' not in v.keys() and 'phone' in dict1[k].keys():
#print(k,v['name'])
dict_base[k]['phone'] = dict1[k]['phone']
for k, v in dict1.items():
if int(k) in list2 and k not in dict_base.keys():
dict_base[k] = v
print(len(dict_base))
#print(dict_base)
filename = 'data/羊庙人员名单.json'
with open(filename,'r') as fl:
dict2 = json.load(fl)
i = 1
for k, v in dict_base.items():
if 'bh' not in v.keys():
name = v['name']
n = 0
for k1,v1 in dict2.items():
if name == v1['name']:
bh = k1
n = n+1
if n ==1:
dict_base[k]['bh'] = bh
else:
print(i,k,v['name'])
i+=1
filename = 'data/杨庙补充汇总信息.json'
with open(filename, 'w') as fl:
json.dump(dict_base, fl, ensure_ascii=False,default=str)
print('ok')In [ ]:
filename = 'data/杨庙补充汇总信息.json'
with open(filename,'r') as fl:
dict1 = json.load(fl)
list_item = ['name','bh','sex','phone','unit','id_num']
list_data = []
for k, v in dict1.items():
list_mx = []
list_mx.append(k)
for item in list_item:
if item in v.keys():
list_mx.append(v[item])
else:
list_mx.append('')
list_data.append(list_mx)
#print(list_data)
filename = 'data/羊庙汇总情况表.xlsx'
wb = openpyxl.Workbook()
sheet = wb.active
#sheet.append(title)
for row in list_data:
sheet.append(row)
wb.save(filename)
print('ok!')In [ ]:
import openpyxl
import json
filename = 'data/杨庙体测明确人员信息(20230328).json'
with open(filename,'r') as fl:
dict2 = json.load(fl)
wb = openpyxl.load_workbook('data/羊庙问卷统计表(成年组).xlsx')
sheet = wb.active
# sheets = wb.sheetnames
dict1 = {}
no_xinli = [108,389,268,270]
sheet = wb.active
data1 =list(sheet.values)
list_bh = data1[0][1:]
del data1[0]
print(len(list_bh))
for i in range(1,len(list_bh)+1):
list2 = []
for item in data1:
list2.append(item[i])
dict1[list_bh[i-1]] = list2
for k, v in dict1.items():
#if 0 in v:
# print(k)
if str(k) not in dict2.keys():
print(k,'不在清理名单中')
#print(dict1)In [ ]:
import openpyxl
import json
filename = 'data/杨庙体测明确人员信息(20230328).json'
with open(filename,'r') as fl:
dict3 = json.load(fl)
wb = openpyxl.load_workbook('data/羊庙问卷统计表(成年组).xlsx')
sheet = wb.active
# sheets = wb.sheetnames
dict1 = {}
list_bh = []
no_xinli = [108,389,268,270]
zy = [2,7,9,11,12,21,24]
sheet = wb.active
data1 =list(sheet.values)
list_bh = data1[0][1:]
del data1[0]
for i in range(1,len(list_bh)+1):
list2 = []
for item in data1:
list2.append(item[i])
dict1[list_bh[i-1]] = list2
#print(dict1)
s = ''
for k,v in dict1.items():
if str(k) in dict3.keys():
if dict3[str(k)]['sex'] ==1:
sex = "m"
else:
sex = "f"
dict2 = {}
list_mx = []
list_mx.append(f'"Gender":"{sex}"')
list_mx.append(f'"Age":"M"')
dict2['surveyId'] = "merge1"
dict2['name'] = dict3[str(k)]['name']
name = dict3[str(k)]['name']
dict2['code'] = str(k)
ss = ''
if k not in no_xinli:
for i in range(0,47):
list_mx.append(f'"q{i+1}M":{v[i]}')
for i in range(1,61):
if i not in zy:
list_mx.append(f'"q{i}":{v[46+i]}')
for i in range(1,27):
list_mx.append(f'"qv{i}":{v[106+i]}')
ss = ','.join(list_mx)
ss ='{'+ss+'}'
dict2['data'] = ss
sj = '2023-03-28 20:02:00'
s= s+f'("merge1","{name}","{str(k)}",\'{ss}\',"{sj}"),'
#print(dict2)
print(s)In [ ]:
import openpyxl
import json
filename = 'data/杨庙体测明确人员信息(20230328).json'
with open(filename,'r') as fl:
dict2 = json.load(fl)
wb = openpyxl.load_workbook('data/羊庙问卷统计表(老年组).xlsx')
sheet = wb.active
# sheets = wb.sheetnames
dict1 = {}
dict3 = {}
no_xinli = [286]
sheet = wb.active
data1 =list(sheet.values)
list_bh = data1[0][1:]
print(list_bh)
del data1[0]
print(len(list_bh))
for i in range(1,len(list_bh)+1):
list2 = []
for item in data1:
list2.append(item[i])
dict1[list_bh[i-1]] = list2
for k, v in dict1.items():
#if 0 in v or ' ' in v:
# print(k)
if str(k) not in dict2.keys():
print(k,'不在清理名单中')
#print(dict1)In [ ]:
import openpyxl
import json
filename = 'data/杨庙体测明确人员信息(20230328).json'
with open(filename,'r') as fl:
dict3 = json.load(fl)
wb = openpyxl.load_workbook('data/羊庙问卷统计表(老年组).xlsx')
sheet = wb.active
# sheets = wb.sheetnames
dict1 = {}
no_xinli = [286]
sheet = wb.active
data1 =list(sheet.values)
list_bh = data1[0][1:]
#print(list_bh)
del data1[0]
for i in range(1,len(list_bh)+1):
list2 = []
for item in data1:
list2.append(item[i])
dict1[list_bh[i-1]] = list2
#print(dict1)
s = ''
for k,v in dict1.items():
if str(k) in dict3.keys():
if dict3[str(k)]['sex'] ==1:
sex = "m"
else:
sex = "f"
dict2 = {}
list_mx = []
list_mx.append(f'"Gender":"{sex}"')
list_mx.append(f'"Age":"O"')
dict2['surveyId'] = "merge1"
dict2['name'] = dict3[str(k)]['name']
dict2['code'] = str(k)
name = dict3[str(k)]['name']
if k not in no_xinli:
for i in range(0,30):
list_mx.append(f'"q{i+1}O":{v[i]}')
for i in range(1,61):
if i not in zy:
list_mx.append(f'"q{i}":{v[29+i]}')
for i in range(1,27):
list_mx.append(f'"qv{i}":{v[89+i]}')
ss = ','.join(list_mx)
ss ='{'+ss+'}'
dict2['data'] = ss
sj = '2023-03-28 20:02:00'
s= s+f'("merge1","{name}","{str(k)}",\'{ss}\',"{sj}"),'
#print(dict2)
print(s)In [ ]:
filename = 'data/merge1.json'
with open(filename,'r') as fl:
dict1 = json.load(fl)
#print(dict1)
filename = 'data/杨庙体测明确人员信息(20230328).json'
with open(filename,'r') as fl:
dict2 = json.load(fl)
dict3 = {}
for k, v in dict1.items():
print(len(v))
for item in v:
phone = item['phone']
dict3.setdefault(phone,{})
#dict3[phone]['data'] = v['data']
for k1,v1 in dict2.items():
if 'phone' in v1.keys() and phone == v1['phone']:
dict3[phone]['bh'] = k1
print(dict3)
for k, v in dict2.items():
for k1, v1 in dict2.items():
if 'bh' not in v.keys():
print(k)In [ ]:
import openpyxl
import json
import time
wb = openpyxl.load_workbook('data/杨庙体测明确人员信息表(20230328).xlsx')
sheet = wb.active
person = {}
for n in range(2, sheet.max_row+1):
code = int(sheet.cell(n, 1).value)
person.setdefault(code, {})
dict1 = {}
name = sheet.cell(n, 2).value
dict1['name'] = name
dict1['sex'] = sheet.cell(n, 3).value
dict1['birth'] = str(sheet.cell(n, 4).value).split(' ')[0]
if sheet.cell(n, 5).value is not None:
dict1['phone'] = str(sheet.cell(n, 5).value)
if sheet.cell(n,6).value is not None:
dict1['unit'] = sheet.cell(n,6).value
person[code] = dict1
filename = 'data/杨庙体测明确人员信息(20230328).json'
with open(filename, 'w') as fl:
json.dump(person, fl, ensure_ascii=False,default=str)
print('ok')In [ ]:
import os,sys,shutil
import json
import math
filename = 'data/杨庙体测明确人员信息(20230328).json'
with open(filename,'r') as fl:
dict1 = json.load(fl)
old = []
depart = []
for k, v in dict1.items():
m_depart = v['unit']
if m_depart not in depart:
depart.append(m_depart)
fi_path = '/data/pdf/ydyb/140/2023-03-29'
# 创建部门办公室
m_path = 'file/140'
for pn in depart:
if not os.path.exists(m_path + '/' + pn):
os.mkdir(m_path + '/' + pn)
fl=os.listdir(fi_path)
for fn in fl:
if os.path.isfile(fi_path + '/' + fn):
ofn = int(fn.split('.')[0])
old.append(ofn)
old.sort()
for n in old:
o_name = f'{fi_path}/{n}.pdf'
unit = dict1[str(n)]['unit']
name = dict1[str(n)]['name']
n_name = f'{m_path}/{unit}/{str(n).rjust(5,"0")}-{name}.pdf'
#print(o_name,n_name)
if not os.path.exists(n_name):
shutil.copyfile(o_name,n_name)
print(n_name)In [ ]:
import os,sys,shutil
import openpyxl
import json
filename = 'data/杨庙体测明确人员信息(20230328).json'
with open(filename,'r') as fl:
dict1 = json.load(fl)
old = []
depart = []
for k, v in dict1.items():
m_depart = v['unit']
if m_depart not in depart:
depart.append(m_depart)
fi_path = '/data/pdf/ydyb/140/2023-03-29'
fl=os.listdir(fi_path)
for fn in fl:
if os.path.isfile(fi_path + '/' + fn):
ofn = int(fn.split('.')[0])
old.append(ofn)
old.sort()
list1 = []
for n in old:
list2 =[]
unit = dict1[str(n)]['unit']
name = dict1[str(n)]['name']
list2 = [str(n).rjust(5,"0"),name,unit]
list1.append(list2)
filename = 'data/杨庙体测报告明细表.xlsx'
wb = openpyxl.Workbook()
sheet = wb.active
title = ['体测编号','姓名','单位']
sheet.append(title)
for row in list1:
sheet.append(row)
wb.save(filename)
print('ok!')In [ ]:
import json
import pymysql
import openpyxl
filename = 'data/杨庙体测明确人员信息(20230328).json'
with open(filename,'r') as fl:
dict1 = json.load(fl)
#print(dict1)
xm = ['qv1','qv2','qv3','qv4','qv5','qv6','qv7','qv8','qv9','qv10','qv11','qv12','qv13','qv14','qv15','qv16','qv17','qv18','qv19','qv20','qv21','qv22','qv23','qv24','qv25','qv26']
title = ['编号','姓名','性别']
for item in xm:
title.append(item)
db = pymysql.connect(host = "localhost",user = "songyi",password = "yylzs",database = "ydyb" )
cursor = db.cursor()
sql = 'SELECT a.phone ,a.name,a.code,a.data FROM Survey as a WHERE a.surveyId ="merge1"'
cursor.execute(sql)
results = cursor.fetchall()
list2 =[]
for result in results:
c=json.loads(result[3])
if result[2] is None:
phone = result[0]
for k,v in dict1.items():
if 'phone' in v.keys() and phone ==v['phone']:
list1 = []
code = k
name = v['name']
list1.append(code)
list1.append(name)
list1.append(v['sex'])
for item in xm:
if item in c.keys():
list1.append(c[item])
else:
list1.append('')
list2.append(list1)
else:
list1 = []
code = result[2]
name = result[1]
list1.append(code)
list1.append(name)
list1.append(v['sex'])
for item in xm:
if item in c.keys():
list1.append(c[item])
else:
list1.append('')
list2.append(list1)
filename = 'data/杨庙脊柱问卷明细表.xlsx'
wb = openpyxl.Workbook()
sheet = wb.active
sheet.append(title)
for row in list2:
sheet.append(row)
wb.save(filename)
print('ok!') In [ ]:
import json
import pymysql
filename = 'data/杨庙体测明确人员信息(20230328).json'
with open(filename,'r') as fl:
dict1 = json.load(fl)
#print(dict1)
xm = ['qv1','qv2','qv3','qv4','qv5','qv6','qv7','qv8','qv9','qv10','qv11','qv12','qv13','qv14','qv15','qv16','qv17','qv18','qv19','qv20','qv21','qv22','qv23','qv24','qv25','qv26']
db = pymysql.connect(host = "localhost",user = "songyi",password = "yylzs",database = "ydyb" )
cursor = db.cursor()
sql = 'SELECT a.phone ,a.name,a.code,a.data FROM Survey as a WHERE a.surveyId ="merge1"'
cursor.execute(sql)
results = cursor.fetchall()
for result in results:
c=json.loads(result[3])
print(c, type(c))In [ ]:
import json
import pymysql
filename = 'data/杨庙体测明确人员信息(20230328).json'
with open(filename,'r') as fl:
dict1 = json.load(fl)
#print(dict1)
xm = ['qv1','qv2','qv3','qv4','qv5','qv6','qv7','qv8','qv9','qv10','qv11','qv12','qv13','qv14','qv15','qv16','qv17','qv18','qv19','qv20','qv21','qv22','qv23','qv24','qv25','qv26']
db = pymysql.connect(host = "localhost",user = "songyi",password = "yylzs",database = "ydyb" )
cursor = db.cursor()
sql = 'SELECT a.phone ,a.name,a.code,a.data FROM Survey as a WHERE a.surveyId ="merge1"'
cursor.execute(sql)
results = cursor.fetchall()
list2 =[]
for result in results:
c=json.loads(result[3])
if 'q1M' in c.keys():
if result[2] is None:
phone = result[0]
for k,v in dict1.items():
if 'phone' in v.keys() and phone ==v['phone']:
list1 = []
code = k
name = v['name']
list1.append(code)
list1.append(name)
list1.append(v['sex'])
list1.append(v['birth'])
list1.append(v['unit'])
list2.append(list1)
else:
list1 = []
code = result[2]
name = result[1]
list1.append(code)
list1.append(name)
list1.append(dict1[code]['sex'])
list1.append(dict1[code]['birth'])
list1.append(dict1[code]['unit'])
list2.append(list1)
filename = 'data/杨庙心理问卷成年组人员明细表.xlsx'
wb = openpyxl.Workbook()
sheet = wb.active
#sheet.append(title)
for row in list2:
sheet.append(row)
wb.save(filename)
print('ok!') In [ ]:
import os,sys,shutil
import json
import math
filename = 'data/杨庙体测明确人员信息(20230328).json'
with open(filename,'r') as fl:
dict1 = json.load(fl)
old = []
depart = []
wb = openpyxl.load_workbook('data/杨庙心理问卷成年组人员明细表.xlsx')
sheet = wb.active
# sheets = wb.sheetnames
list_bh = []
for n in range(1,sheet.max_row+1):
list_bh.append(int(sheet.cell(n, 1).value))
m_depart = sheet.cell(n, 5).value
if m_depart not in depart:
depart.append(m_depart)
fi_path = '/data/pdf/ydyb/140/2023-04-01'
# 创建部门办公室
m_path = 'file/140wenjuan'
for pn in depart:
if not os.path.exists(m_path + '/' + pn):
os.mkdir(m_path + '/' + pn)
fl=os.listdir(fi_path)
for fn in fl:
if os.path.isfile(fi_path + '/' + fn):
ofn = int(fn.split('.')[0])
if ofn in list_bh:
old.append(ofn)
old.sort()
for n in old:
o_name = f'{fi_path}/{n}.pdf'
unit = dict1[str(n)]['unit']
name = dict1[str(n)]['name']
n_name = f'{m_path}/{unit}/{str(n).rjust(5,"0")}-{name}.pdf'
#print(o_name,n_name)
if not os.path.exists(n_name):
shutil.copyfile(o_name,n_name)
print(n_name)In [ ]:
import os,sys,shutil
import json
import math
filename = 'data/杨庙体测明确人员信息(20230328).json'
with open(filename,'r') as fl:
dict1 = json.load(fl)
wb = openpyxl.load_workbook('data/杨庙运动风险筛查统计表.xlsx')
sheet = wb.active
# sheets = wb.sheetnames
list_gxy = []
for n in range(2,sheet.max_row+1):
code = sheet.cell(n, 1).value
if sheet.cell(n, 3).value is not None:
code = sheet.cell(n, 1).value
gxy = sheet.cell(n, 3).value
if str(code) in dict1.keys() and int(gxy) ==1:
list_gxy.append(str(code))
print(list_gxy)
In [ ]:
import json
import pymysql
filename = 'data/杨庙体测明确人员信息(20230328).json'
with open(filename,'r') as fl:
dict1 = json.load(fl)
#print(dict1)
db = pymysql.connect(host = "localhost",user = "songyi",password = "yylzs",database = "ydyb" )
cursor = db.cursor()
sql = 'SELECT a.phone ,a.name,a.code,a.data FROM Survey as a WHERE a.surveyId ="merge1"'
cursor.execute(sql)
results = cursor.fetchall()
list_sm =[]
for result in results:
c=json.loads(result[3])
if 'qv7' in c.keys() and c['qv7'] ==1:
if result[2] is None:
phone = result[0]
for k,v in dict1.items():
if 'phone' in v.keys() and phone ==v['phone']:
list_sm.append(k)
else:
list_sm.append(result[2])
print(list_sm)In [ ]:
import json
import pymysql
filename = 'data/杨庙体测明确人员信息(20230328).json'
with open(filename,'r') as fl:
dict1 = json.load(fl)
#print(dict1)
db = pymysql.connect(host = "localhost",user = "songyi",password = "yylzs",database = "ydyb" )
cursor = db.cursor()
sql = 'SELECT a.phone ,a.name,a.code,a.data FROM Survey as a WHERE a.surveyId ="merge1"'
cursor.execute(sql)
results = cursor.fetchall()
list_jz =[]
for result in results:
c=json.loads(result[3])
if ('qv1' in c.keys() and c['qv1'] ==1) or ('qv18' in c.keys() and c['qv18'] ==1):
if result[2] is None:
phone = result[0]
for k,v in dict1.items():
if 'phone' in v.keys() and phone ==v['phone']:
list_jz.append(k)
else:
list_jz.append(result[2])
print(list_jz)In [ ]:
dict2 = {}
dict2.setdefault('高血压',[])
dict2['高血压'] = list_gxy
dict2.setdefault('失眠',[])
for item in list_sm:
if item not in list_gxy:
dict2['失眠'].append(item)
dict2.setdefault('脊柱调理',[])
for item in list_jz:
if item not in list_gxy and item not in list_sm:
dict2['脊柱调理'].append(item)
list_other = []
for item in dict1.keys():
if item not in list_gxy and item not in list_sm and item not in list_jz:
list_other.append(item)
dict2['整体调理'] = list_other
print(dict2)
list1 = []
for k, v in dict2.items():
for item in v:
list2 = [k,item,dict1[item]['name'],dict1[item]['sex'],dict1[item]['birth'],dict1[item]['unit']]
list1.append(list2)
filename = 'data/杨庙社区分组情况表.xlsx'
wb = openpyxl.Workbook()
sheet = wb.active
#sheet.append(title)
for row in list1:
sheet.append(row)
wb.save(filename)
print('ok!')
In [79]:
import psycopg2
from psycopg2 import extras as ex
import openpyxl
wb = openpyxl.load_workbook('data/杨庙社区分组情况表.xlsx')
sheet = wb.active
data_list = []
for n in range(2, sheet.max_row+1):
code = int(sheet.cell(n, 3).value)
name = sheet.cell(n, 4).value
birth = str(sheet.cell(n, 5).value).split(' ')[0]
unit = sheet.cell(n, 6).value
category = sheet.cell(n, 2).value
if sheet.cell(n, 7).value is not None:
phone = str(sheet.cell(n, 7).value)
else:
phone = ''
xb = int(sheet.cell(n, 8).value)
if xb ==1:
sex = '男'
else:
sex = '女'
data_list.append((code,name,sex,birth,category,unit,phone))
#print(data_list)
conn = psycopg2.connect(database="mycrm", user="postgres", password="songyi", host="localhost", port="5432")
cursor = conn.cursor()
sql = 'insert into yangmiao_fenzu (code,name,sex,birth,category,unit,phone) values %s'
ex.execute_values(cursor, sql, data_list, page_size=10000)
conn.commit()
cursor.close()
conn.close()In [ ]: