[*NEW*] Csv to Database NuGet Library.

Joever Monceda
2 min readJun 19, 2021

This C# library will support Csv to Database table creation using Mssql and Npgsql programmatically with minimal line of codes.

NuGet

Csv to Database

Requirements

  • .NET Core 3.1
  • VSCode
  • MSSQL
  • NPGSQL

How to use:

  • Go to Tools and select Manage Nuget Packages and Search for CsvToDb library.
    Install-Package CsvToDb -Version 1.0.2
private readonly string _connString;

public UploadController(IConfiguration config)
{
_connString = config["CONNECTIONSTRING_MSQL"];
}

[RequestFormLimits(ValueLengthLimit = int.MaxValue, MultipartBodyLengthLimit = int.MaxValue)]
[DisableRequestSizeLimit]
[HttpPost("csv-to-db")]
[Consumes("multipart/form-data")]
public async Task<IActionResult> TestCsvToDb(IFormFile file)
{
//From IFormFile
await CsvToDbService.ExecuteAsync(file, new ToDbOptions()
{
TableName = "Customer",
Delimiter = ",",
UsedMssqlDb = true,
UsedSnakeCase = true,
DbConnectionString = _connString,
});
//From file path
await CsvToDbService.ExecuteAsync(@"{csv-file-path}", new ToDbOptions()
{
TableName = "Customer",
Delimiter = "|",
UsedMssqlDb = false,
UsedSnakeCase = true,
DbConnectionString = _connString,
});

return Ok("Success!");
}

note: It will upload 1 million rows and 15 columns within a minute.

Check Database:

  1. Go to your database Npgsql or Mssql and check if the records are successfully created on the said table name.

note: I did not implement any logs for this library especially on connection string for security purposes.
You can use local database to persist temporarily the records from uploaded csv.

License

Copyright © 2020 Joever Monceda

Linkedin: Joever Monceda
Medium: Joever Monceda
Twitter @_EthanHunt07
Facebook: Ethan Hunt

Looking for a JOB? Signup @ jobbhy and be notified!
https://jobbhy.com

Want to post a JOB as employer? Contact and be one us!
https://www.jobbhy.com/#/contactus

Read more about jobbhy:
Jobbhy — Smart Hiring | Job Vacancies | Recruitment
https://joever-monceda.medium.com/jobbhy-smart-hiring-job-vacancies-recruitment-f9fc9dad113b

Facebook:
https://www.facebook.com/jobbhy

LinkedIn:
https://www.linkedin.com/company/jobbhy-co-ltd

Twitter:
https://twitter.com/Jobbhy_

JSanitizer (Configurable sanitizer for XML and JSON.)
https://joever-monceda.medium.com/jsanitizer-nuget-library-5d2cdedb435d

--

--