import pymysql
db = pymysql.connect(
host="124.70.xxx.xxx",
user="root",
password="3xxxx",
database="novel"
)
mycursor = db.cursor()
phone = ( (phone,phone) for phone in range(13100110000,13100112000))
sql = "INSERT INTO `novel`.`user`( `username`, `password`, `nick_name`, `user_photo`, `user_sex`, `account_balance`, `status`, `create_time`, `update_time`) VALUES (%s, '25d55ad283aa400af464c76d713c07ad', %s, NULL, NULL, 0, 0, '2022-09-07 21:53:04', '2022-09-07 21:53:04');"
try:
# 执行sql语句
mycursor.executemany(sql,phone)
# 提交到数据库执行
db.commit()
except Exception as e:
print(e)
# 如果发生错误则回滚
print("发生错误了")
db.rollback()