Put the database open outside the loop so that it is called only once. Re-accessing it from a loop of 10,000 lines can cause memory problems.
Check lastErrorCode on the db object after each executeUpdate and NSLog lastErrorMessage if it is not equal to zero.
Fix at intervals by increasing the counter and using module arithmetic, for example
counter++; if (mod(counter,500) ){ [self.db commit]; }
Consider using python to load the database outside of your iOS project.
source share