Skip to content

This library let you import bulk csv file to the DB in a high efficiency.

License

Notifications You must be signed in to change notification settings

Akkoongitit/BulkCsvImporter

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 

Repository files navigation

BulkCsvImporter

This library let you import bulk csv file to the DB in a high efficiency.

Realized with the batch importing feature provided by DB.(Only support SQL Server)

The columns mapping between DB table columns and csv columns are based on the configuration.

This library is depend on .Net Framework 4.6.2

Dependent library:

Dependent of database feature:

Supported data type of database:

  • uniqueidentifier
  • bit
  • datetime
  • decimal
  • int
  • varchar
  • nvarchar

Here is how to use it:

//Define the column names mapping from csv to database table as a string array, the first column must be the PK column and should use guid as data type.
var columns = "Id,EmployeeNo,Name,Age,Column3".Split(',').ToList();
//Define the business PK as a string array, these columns should be included in the columns defined in above.
var keys = new List<string>() { "EmployeeNo" };
//Define the connection string.
var connectionString = "data source=.;initial catalog=sa;persist security info=True;user id=sa;password=123456;MultipleActiveResultSets=True;";

//Then here you can start the import.
var singleFileImportOption = new SingleFileImportOption()
                            .BuildDatabaseConnect(DatabaseType.SQLServer, connectionString)
                            //The second arg is the table name that you would like the csv import to.
                            .BuildImportTarget(true, "OverdueInfo", columns, keys)
                            .BuildLocalFileSource(@"E:\OverdueInfo.csv");
var importer = ImporterFactory.CreateInstance(singleFileImportOption);
importer.Import();

About

This library let you import bulk csv file to the DB in a high efficiency.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 100.0%