CsvToDb 1.0.2

dotnet add package CsvToDb --version 1.0.2                
NuGet\Install-Package CsvToDb -Version 1.0.2                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CsvToDb" Version="1.0.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CsvToDb --version 1.0.2                
#r "nuget: CsvToDb, 1.0.2"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install CsvToDb as a Cake Addin
#addin nuget:?package=CsvToDb&version=1.0.2

// Install CsvToDb as a Cake Tool
#tool nuget:?package=CsvToDb&version=1.0.2                

Csv To Database

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

Requirements

  • .NET Core 3.1
  • VSCode
  • MSSQL
  • NPGSQL

Running the application:

  1. Server Command line:
  • dotnet run or dotnet watch run

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

License: MIT
Copyright (c) 2020 Joever Monceda

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

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.1 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.2 367 6/21/2021
1.0.1 320 6/19/2021