Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3792062
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T12:33:53+00:00 2026-05-19T12:33:53+00:00

Hi i am using follwing code to insert bulk data from arrays into sqlite

  • 0

Hi i am using follwing code to insert bulk data from arrays into sqlite db…but it is extremely slow…please advise…
Am I using the right approach?

sqlite3 *db1=nil;
db1 = [One2GuideUAppDelegate getNewDBConnection];

sqlite3_stmt *init_statement = nil;
@try
{   


    if(init_statement == nil)
    {
        const char *sql = "insert into tblBrand(intBId,intVersion,intLikes,intDontLikes,strName,strDesc,strWebsite,intEst,strFounder,strLogo,strThumbnail) values(?,?,?,?,?,?,?,?,?,?,?)";
        if(sqlite3_prepare_v2(db1, sql, -1, &init_statement, NULL) != SQLITE_OK)
            NSAssert1(0,@"Error: Failed to prepare statement with message '%s'.",sqlite3_errmsg(db1));  
    }

    for(int br=0;br<[brands count];br++)
    {
        BrandVO *brandVO=[brands objectAtIndex:br ];
        NSString *brandID=brandVO.brandID;
        NSString *brandVer=brandVO.brandVersion;
        NSString *brandLikes=brandVO.likes;
        NSString *brandDontLikes=brandVO.dontLikes;
        NSString *brandName=brandVO.name;
        NSString *brandDesc=brandVO.description;
        NSString *brandWeb=brandVO.url;
        NSString *brandEstb=brandVO.establishedYear;
        NSString *brandFounder=brandVO.founders;
        NSString *brandLogo=brandVO.logoURL;
        NSString *brandthumb=brandVO.thumbnailURL;





    sqlite3_bind_int(init_statement, 1, [brandID intValue]);
    sqlite3_bind_int(init_statement, 2, [brandVer intValue]);
    sqlite3_bind_int(init_statement, 3, [brandLikes intValue]);
    sqlite3_bind_int(init_statement, 4, [brandDontLikes intValue]);
    sqlite3_bind_text(init_statement, 5,[brandName UTF8String],-1,SQLITE_TRANSIENT);
    sqlite3_bind_text(init_statement, 6,[brandDesc UTF8String],-1,SQLITE_TRANSIENT);
    sqlite3_bind_text(init_statement, 7,[brandWeb UTF8String],-1,SQLITE_TRANSIENT);
    sqlite3_bind_int(init_statement, 8,[brandEstb intValue]);
    sqlite3_bind_text(init_statement, 9,[brandFounder UTF8String],-1,SQLITE_TRANSIENT);
    sqlite3_bind_text(init_statement, 10,[brandLogo UTF8String],-1,SQLITE_TRANSIENT);
    sqlite3_bind_text(init_statement, 11,[brandthumb UTF8String],-1,SQLITE_TRANSIENT);


    if(SQLITE_DONE != sqlite3_step(init_statement))
        NSAssert1(0, @"Error while inserting data. '%s'", sqlite3_errmsg(db1));

    sqlite3_reset(init_statement);
        }

}

@catch (NSException *ex) 
{
    @throw ex;
}
@finally 
{
    if(init_statement)sqlite3_finalize(init_statement);
    sqlite3_close(db1);
}

Thanks,

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T12:33:54+00:00Added an answer on May 19, 2026 at 12:33 pm

    Wrap your insert statements in transactions with BEGIN TRANSACTION and END TRANSACTION. This usually speeds up bulk inserts a lot.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the following php pdo code to insert data into mysql database, the
I want to insert data into a table using the following code public User
I'm doing a BULK INSERT into a table using a FMT format file, but
i am inserting data into data base using following code but data is not
I'm using the following code: $query = $dbh->prepare(INSERT into crm_order_errors .SET (order_id, number_of_attempts, last_attempt)
I have following code for inserting data into database using PDO. It inserts data
Android: I am using following code to insert image into album According to description
I'm using the following code to insert a row with a timestamp column into
I am doing a bulk insert: // Get the data into the DataTable //dtData
I'm using the following code: INSERT INTO tForeignLanguage ([Name]) VALUES ('Араб') this value inserted

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.