How do I perform a batch insert in Django?

前端 未结 5 1696
隐瞒了意图╮
隐瞒了意图╮ 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:09

    No it is not possible because django models are objects rather than a table. so table actions are not applicable to django models. and django creates an object then inserts data in to the table therefore you can't create multiple object in one time.

提交回复
热议问题