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)文章
unity實(shí)現(xiàn)場(chǎng)景跳轉(zhuǎn)
這篇文章主要為大家詳細(xì)介紹了unity實(shí)現(xiàn)場(chǎng)景跳轉(zhuǎn),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2021-04-04字符串陣列String[]轉(zhuǎn)換為整型陣列Int[]的實(shí)例
下面小編就為大家分享一篇字符串陣列String[]轉(zhuǎn)換為整型陣列Int[]的實(shí)例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2017-12-12c#遠(yuǎn)程html數(shù)據(jù)抓取實(shí)例分享
這篇文章主要介紹了c#遠(yuǎn)程html數(shù)據(jù)抓取的方法,大家參考使用吧2013-12-12C#實(shí)現(xiàn)炫酷啟動(dòng)圖-動(dòng)態(tài)進(jìn)度條效果
這篇文章主要介紹了基于C#實(shí)現(xiàn)炫酷啟動(dòng)圖-動(dòng)態(tài)進(jìn)度條 效果,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2019-05-05C#獲取微信小程序的云數(shù)據(jù)庫(kù)中數(shù)據(jù)的示例代碼
本文主要介紹了C#獲取微信小程序的云數(shù)據(jù)庫(kù)中數(shù)據(jù)的示例代碼,文中通過示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2021-08-08