I'm using bulk_create to insert thousand of users once:
new_users_bulk_list.append(User(user_id=user_id, date_of_birth=dob))
if len(new_users_bulk_list) >= settings.BULK_LIMIT:
try:
User.objects.bulk_create(new_users_bulk_list)
new_users_bulk_list[:] = []
except Exception as e:
print("Error: Creating users " + str(e))
and bulk_update to update many records:
user_bulk.append(user_sequence)
if len(user_bulk) == settings.BULK_LIMIT:
bulk_update(user_bulk)
user_bulk[:] = []
If bulk_create or bulk_update fails in creating/updating records, how can I identify these failed records? Is there a way to catch specific failed records ?
Thank you,