I come from a mysql background where if I want to insert a record I can use an INSERT IGNORE command so that I can just bung rows in and if there's a conflict just ignore it.
Now, with a Django project I'm working on I'm using postgresql, and issue multiple saves in a loop. However, I think if I get an IntegrityError (which I'm ignoring, see code below) then I lose loads of objects that I'm trying to insert.. how should I fix this:
for thing in things:
try:
#potentially dangerous save..
obj = Thing(stuff=10)
obj.save()
except IntegrityError:
pass
If say, on the 5th go round the loop an IntegrityError happens, which objects will get inserted into the DB?