我想用會計系統中的電子表格更新客戶表格。不幸的是,我不能清除數據並重新加載所有數據,因爲表中有一些不在導入數據中的記錄(不要問)。批量更新表格
對於2000條記錄,這需要大約5分鐘,我想知道是否有更好的方法。
for row in data:
try:
try:
customer = models.Retailer.objects.get(shared_id=row['Customer'])
except models.Retailer.DoesNotExist:
customer = models.Retailer()
customer.shared_id = row['Customer']
customer.name = row['Name 1']
customer.address01 = row['Street']
customer.address02 = row['Street 2']
customer.postcode = row['Postl Code']
customer.city = row['City']
customer.save()
except:
print formatExceptionInfo("Error with Customer ID: " + str(row['Customer']))
謝謝你,我會看看。 – alj 2010-10-04 10:42:31