Addressing the last part of your question:
Perhaps somebody knows the much simpler thing: how to do bulk inserts
of CSV files into SQLite...
Given you need to import a few thousand (or a cpl of million) records into sqlite from a CSV file,
When there is no direct support for csv data import via the select or insert commands,
And the iterative row by row reading & inserting is not performant
Then a practical alternative is to use the "sqlite?.exe" & the import command via shell execute from your c# code.
loadcsvtosqlite.cs
Process proc = new Process {
StartInfo = new ProcessStartInfo {
FileName = @"loadcsvtosqlite.bat",
Arguments = @"",
UseShellExecute = true,
RedirectStandardOutput = false,
CreateNoWindow = true
}
};
proc.Start();
proc.WaitForExit();
loadcsvtosqlite.bat
sqlite3.exe "db name" < loadcsv.sql
loadcsv.sql
drop table if exists <table name>;
create table <table name> (field1 datatype, field2 datatype ....);
.separator ","
.import <csv file name> <table name>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…