title: Insert bulk CSV data into SQLite in less time using c# code
body: <p>I have 3 million data in my CSV file. I would like to insert these bulk data into SQLite database within 10 -15 minutes. Normally it takes 20 minutes using below code. </p>
  
  <p>My Sample:</p>
  
  <pre><code>SQLiteConnection con = new SQLiteConnection("Data Source="D:\\SQLiteData.db;Version=3;New=False;Compress=True;");
          if (!File.Exists("D:\\SQLiteData.db"))
          {
              SQLiteConnection.CreateFile("D:\\SQLiteData.db");
          }
          con.Open();
          SQLiteCommand com = con.CreateCommand();
          com.Transaction = con.BeginTransaction();
          com.CommandText = "CREATE TABLE Sample([ELEMENT_ID] real,[DATE] datetime,[COMMENT] real);"
              com.ExecuteNonQuery();
          com.CommandText = "INSERT INTO [Sample] VALUES(@C0,@C1,@C2)";
          using (var fileStream = new FileStream("E:\\comma.csv", FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
          using (StreamReader streamReader = new StreamReader(fileStream))
          {
              using (CsvReader reader = new CsvReader(streamReader))
              {
                  reader.ValueSeparator =’,’;
                  reader.ReadHeaderRecord();
                  while (reader.HasMoreRecords)
                  {
                      DataRecord record = reader.ReadDataRecord();
                      com.Parameters.Clear();
                      for (int i = 0; i &lt; reader.HeaderRecord.Count; i++)
                      {
                          com.Parameters.AddWithValue("@c" + i, string.Empty);
                      }
                      com.ExecuteNonQuery();
                  }
              }
          }
  </code></pre>
  
  <p>Can anyone suggest me an alternate way to move bulk CSV data into SQLite in less time? </p>