Django Mysql Bulk_Create Ids

239 views
Skip to first unread message

Rohan Nahata

unread,
Sep 27, 2020, 7:15:11 PM9/27/20
to Django users
How can we make this happen? 
What steps would be needed so that bulk_create ends up returning the ids of the items that just got created? I don't want to be machine gunning my db with save statements to retrieve ids. 

Simon Charette

unread,
Sep 28, 2020, 9:58:04 AM9/28/20
to Django users
Unfortunately MySQL doesn't support an equivalent of the RETURNING clause on PostgreSQL/Oracle.

In other words MySQL only allows to retrieve an inserted row auto id one at a time through its non-standard LAST_INSERT_ID function.

That prevents any attempts at inserting multiple rows and retrieving their corresponding primary key.

Cheers,
Simon

Dvs Khamele

unread,
Oct 11, 2020, 1:40:42 PM10/11/20
to django...@googlegroups.com
Hi do you hire contract based python/django freelancer?
We can help you in this and related techincal tasks at fair prices. Reply or send email to div...@pythonmate.com
Best Regards, 
Divyesh Khamele,
Pythonmate

On Mon, 28 Sep 2020, 4:44 am Rohan Nahata, <rohan...@gmail.com> wrote:
How can we make this happen? 
What steps would be needed so that bulk_create ends up returning the ids of the items that just got created? I don't want to be machine gunning my db with save statements to retrieve ids. 

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/05b8f31e-f4e7-4f3f-b94a-2dea27568102n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages