# @Author : Kant
# @Time : 2022/1/22 16:37
'''
Insert 100000 pieces of data
'''
import pymysql
# Connect = connect = Connection = connections.Connection
connect_db=pymysql.Connect(host='localhost',port=3306,database='index_test',user='root',password='root',charset='utf8')
cur=connect_db.cursor()
# Turn on auto submit
connect_db.autocommit(True)
sql_str='''insert into test_index values(%s,%s)'''
# If Auto submit is enabled , The transaction needs to be opened , A transaction has been implicitly opened when the cursor object is created
# connect_db.begin()
n=0
for i in range(100000):
t = cur.execute(sql_str,[0,f'data_{i+1}'])
print(f' The first {i+1} Data inserted successfully ')
n+=t
print(f'{n} Data inserted successfully ...')
cur.close()
connect_db.close()