CsvToDb 1.0.2
dotnet add package CsvToDb --version 1.0.2
NuGet\Install-Package CsvToDb -Version 1.0.2
<PackageReference Include="CsvToDb" Version="1.0.2" />
paket add CsvToDb --version 1.0.2
#r "nuget: CsvToDb, 1.0.2"
// 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:
- 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:
- 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 (c) 2020 Joever Monceda
Linkedin: Joever Monceda
Medium: Joever Monceda
Twitter @_EthanHunt07
Facebook: Ethan Hunt
Product | Versions 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. |
-
.NETCoreApp 3.1
- Microsoft.AspNetCore.Http.Features (>= 5.0.7)
- Npgsql (>= 6.0.0-preview2)
- System.Data.SqlClient (>= 4.8.2)
- Z.EntityFramework.Extensions.EFCore (>= 5.1.39)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.