# 如何向数据库一次性插入多条数据 # 方法一:效率极低,不推荐使用 for i in range(1000): models.Book.objects.create(title=f'第{i}本书') # 方法二 # bulk_create book_list = [] for i in range(100000): book_list.append(models.Book(title=f'第{i}本书')) models.Book.objects.bulk_create(book_list)…
文档 https://github.com/jamis/bulk_insert class Book < ActiveRecord::Base end book_attrs = ... # some array of hashes, for instance Book.bulk_insert do |worker| book_attrs.each do |attrs| worker.add(attrs) end end #向数据库批量插入数据"d_data_yyyymm_params&qu…