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

  • SEARCH
  • Home
  • 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 8833367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T08:45:48+00:00 2026-06-14T08:45:48+00:00

Is there a way to Import an entire CSV file into SQLite through the

  • 0

Is there a way to Import an entire CSV file into SQLite through the C Interface?

I’m aware of the commandline import that looks like this,

   sqlite> .mode csv <table>
   sqlite> .import <filename> <table>

but I need to be able to do this in my program.

I should also note that I have successfully created a CSV reader in C++ that reads in a CSV file and inserts its content to a table line by line.

This gets the job done but with a CSV containing 730k lines this method takes ~20 minutes to load which is WAY too long. (This is going to be around average size of the stuff being processed)

(Machine: Intel(R) Core(TM)2 Duo CPU E8500 @ 3.16GHz 3.17GHz, 4.0 GB Ram, Windows 7 64 bit, Visual studios 2010)

This is unacceptable for my project so I need a faster way, something taking around 2-3 minutes.

Is there a way to reference the file’s memory location so Import isn’t necessary? If so is access of the information slow?

Can SQLite take the CSV file as binary data? Would this make importing the file any faster?

Ideas?

Note: I’m using the “:memory:” option with the C Interface to load the DB in memory to increase speed (I hope).

EDIT

After doing some more optimizing I found this. It explains how you can group insert statements into 1 transaction by writing.

BEGIN TRANSACTION;
INSERT into TABLE VALUES(...);
...Million more INSERT statements
INSERT into TABLE VALUES(...);
COMMIT;

This created a HUGE improvement in performance.

Useful Related Side Note

Also if you’re looking to a create table from a query’s results or Insert query results into a table try this for creating tables or this for inserting results into a table.

The insert link might not be obvious for inserting into a table. The query to do that looks like this.

INSERT INTO [TABLE] [QUERY]

where [TABLE] is the table you want the results of [QUERY] the query you’re running to go into.

  • 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-06-14T08:45:49+00:00Added an answer on June 14, 2026 at 8:45 am

    I have successfully created a CSV reader in C++ that reads in a CSV file and inserts its content to a table line by line… takes ~20 minutes to load

    Put all your inserts into a single transaction – or at least batch up 100 or 1000 rows per transaction – and I would expect your program to run much faster.

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

Sidebar

Related Questions

Is there a way to import data from a JSON file into R? More
Is there a way to programatically import an entire database from a file with
Is there a way to import HTML snippets or HAML snippets into a HAML
Is there an easy way to import a large .sql file of my database
Is there a way to take HTML and import it to excel so that
Is there way to copy a file into Plone with WebDAV and have Plone
I have a Model called Version that looks like this: from google.appengine.ext import db
I need a way to import the entire Python standard library into my program.
Sorry for newbie question but is there a way to import someone else commit
Is there any way to read the asp.net Import directives at runtime? I have

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.