Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Import/Export CSV from SQLite from C# code

Tags:

c#

.net

sqlite

I am trying to figure out an eazy way to load CSV file into SQLite DB using System.Data.SQLite

I saw commandline way to do that i.e .Import mydata.csv mytable

But I need to do this via C# code. Any Idea?

like image 247
SysAdmin Avatar asked Mar 05 '10 10:03

SysAdmin


People also ask

How we can call the import CSV file in sqlite3?

You can import a CSV file into SQLite table by using sqlite3 tool and . import command. This command accepts a file name, and a table name. Here, file name is the file from where the data is fetched and the table name is the table where the data will be imported into.

Which command is used to copy a data from SQLite table to CSV file?

To copy a table or query to a csv file, use either the \copy command or the COPY command.


1 Answers

you can create OleDbConnection to CSV file (just google it, it is very easy) then load rows to DataSet, then put that dataset into Sqlite by SqliteConnection. Few lines of code.

like image 51
Andrey Avatar answered Sep 28 '22 00:09

Andrey