How do I perform a batch insert in Django?

前端 未结 5 1697
隐瞒了意图╮
隐瞒了意图╮ 2020-12-23 20:12

In mysql, you can insert multiple rows to a table in one query for n > 0:

INSERT INTO tbl_name (a,b,c) VALUES(1,2,3),(4,5,6),(7,8,9), ..., (n-2, n-1, n);
         


        
5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-23 21:10

    These answers are outdated. bulk_create has been brought in Django 1.4:

    https://docs.djangoproject.com/en/dev/ref/models/querysets/#bulk-create

提交回复
热议问题