I am using following code to insert rows more than 5000 in my ios app. if i am not using line sqlite3_close(dbv); statement i got an error unable to open database. and if i use the statement sqlite3_close(dbv) data insertion taking around 10-15 mins. what can i do to insert record faster without getting error.
-(void)insertrecordIntoTable:(NSString*)SQLStatement
{
NSString *sqlStr=SQLStatement;
const char *sql=[sqlStr UTF8String];
const char* key = [@"StrongPassword" UTF8String];
sqlite3_stmt *statement1;
@try {
int res = sqlite3_open([[self.databaseURL path] UTF8String], &dbv);
if (res != SQLITE_OK)
sqlite3_open([[self.databaseURL path] UTF8String], &dbv);
sqlite3_key(dbv, key, (int)strlen(key));
if(sqlite3_prepare_v2(dbv, sql, -1, &statement1, nil)==SQLITE_OK)
{
NSLog(@"done");
}
else
{
NSLog(@"the error occurred here is %s ",sqlite3_errmsg(dbv));
}
res =sqlite3_step(statement1);
if(res !=SQLITE_DONE)
NSLog(@"Error upadating table");
sqlite3_finalize(statement1);
sqlite3_close(dbv);
}
@catch (NSException *exception) {
}
@finally {
sql=NULL;
sqlStr=NULL;
SQLStatement=NULL;
}
}