Hello,
I have doubts about the use of db.commit(). I'm using db.commit() in task.py with celery and this is more or less what I have.
I have one task that updates records massively, and it has around 3 or 4 for loops nested while every loop updates different records.
My question is where the db.commit() should go. I'dont know if it should go at the end of the whole process or between for loops.
Ex 1:
for i in values:
db.table1.update_or_insert()
for x in values2:
db.table2.insert(=
for x in values33:
db.table2.update()
db.commit()
Ex 2:
for i in values:
db.table1.update_or_insert()
for x in values2:
db.table2.insert(=
for x in values33:
db.table2.update()
db.commit()
I've tested and worked in both cases, but I would like to know what is the appropriate place to declare it.
Cheers.
Chris.