Imagine that you have the following situation:
for i in xrange(100000):
account = Account()
account.foo = i
account.save
Obviously, the 100,000 statements INSERTexecuted by Django will take some time. It would be better to combine all these INSERTinto one big one INSERT. Here is what I hope I can do:
inserts = []
for i in xrange(100000):
account = Account()
account.foo = i
inserts.append(account.insert_sql)
sql = 'INSERT INTO whatever... ' + ', '.join(inserts)
Is there a way to do this with QuerySet, without manually creating all of these statements INSERT?
source
share