欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

C#/.Net 中快速批量給SQLite數(shù)據(jù)庫(kù)插入測(cè)試數(shù)據(jù)

 更新時(shí)間:2015年06月16日 10:04:20   投稿:junjie  
這篇文章主要介紹了C#/.Net 中快速批量給SQLite數(shù)據(jù)庫(kù)插入測(cè)試數(shù)據(jù),本文直接給出實(shí)例代碼,需要的朋友可以參考下

使用transaction:

 var stopwatch = new Stopwatch();
      using (var cmd = new SQLiteCommand(db_con))
      using (var transaction = db_con.BeginTransaction())
      {
        stopwatch.Reset();
        stopwatch.Start();
        foreach (var item in sorted)
        {
          sql = string.Format("insert into db (st1, st2) values ('{0}', {1})", item.Key.Replace("'", "''"), item.Value);
          cmd.CommandText = sql;
          cmd.ExecuteNonQuery();
          ++readCnt;
          if (++readCnt % 1000000 == 0)
          {
            Console.Write("\rDumped {0} lines...", readCnt);
          }
        }
        Console.Write("\rCommitting....");
        transaction.Commit();
        stopwatch.Stop();
        Console.Write("\rDumped {0} lines using {1} seconds...", readCnt, stopwatch.Elapsed.TotalSeconds);
      }

相關(guān)文章

最新評(píng)論