Flask-SQLAlchemy批量插入数据性能测试
startTime = time.time()
for i in range(10000):
db.session.add(
Test(
blog_name='阿汤博客{}'.format(i),
blog_url='https://www.amd5.cn/'.format(i),
blog_desc='我是阿汤博客,地址是https://www.amd5.cn/'.format(i),
create_time=datetime.datetime.now()
)
)
db.session.commit()
endTime = time.time()
diff = round(endTime - startTime, 3)
print("耗时:{}s").format(diff)
耗时:95.468sLast updated