我想将我从 Web 服务获得的 40000 条记录插入到我的 iPad 应用程序的 sqlite 数据库中。
我写了以下代码,但是大约需要 20 分钟,有没有更快的方法?
- (NSArray *)insertPriceSQLWithPrice:(Price *) price
{
SQLiteManager *dbInfo = [SQLiteManager sharedSQLiteManagerWithDataBaseName:@"codefuel_catalogo.sqlite"];
sqlite3 *database;
NSString *querySQL=[self formatStringQueryInsertWithTable:@"prices_list" andObject:price];
if(sqlite3_open([dbInfo.dataBasePath UTF8String], &database) == SQLITE_OK)
{
sqlite3_stmt * compiledStatement;
const char *query_stmt = [querySQL UTF8String];
int result = sqlite3_prepare_v2(database, query_stmt, -1, &compiledStatement, NULL);
if (result == SQLITE_OK)
{
int success = sqlite3_step(compiledStatement);
NSLog(@"el numero de success es -> %i",success);
if (success == SQLITE_ERROR)
NSLog(@"Error al insertar en la base de datps");
}
else
NSLog(@"Error %@ ERROR!!!!",querySQL);
sqlite3_finalize(compiledStatement);
}
sqlite3_close(database);
return nil;
}