mysql.connector-批量插入8条记录
时间:2021-07-01 10:21:17
帮助过:6人阅读
= mysql.connector.Connect(
host=‘localhost‘,
user=‘root‘,
passwd=‘admin‘,
database=‘testcode‘
)
print(
‘1.‘,conn)
cmd = conn.
cursor() # 光标行
ssql=‘insert into test(sname,age)values(%s,%s)‘
name=[(‘susu1‘,11),(‘susu2‘,12),(‘susu3‘,13),(‘susu4‘,14),(‘susu5‘,15),(‘susu6‘,16),(‘susu7‘,17),(‘susu8‘,18)]
cmd.executemany(ssql,name)
conn.commit()
print(
‘4.‘,cmd.
rowcount,
‘条记录插入成功‘)
mysql.connector-批量插入8条记录
标签:imp mys tco tab code span roo class 批量插入