Rivulet.Sql.MySql
1.3.0
dotnet add package Rivulet.Sql.MySql --version 1.3.0
NuGet\Install-Package Rivulet.Sql.MySql -Version 1.3.0
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="Rivulet.Sql.MySql" Version="1.3.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Rivulet.Sql.MySql" Version="1.3.0" />
<PackageReference Include="Rivulet.Sql.MySql" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Rivulet.Sql.MySql --version 1.3.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Rivulet.Sql.MySql, 1.3.0"
#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.
#:package Rivulet.Sql.MySql@1.3.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Rivulet.Sql.MySql&version=1.3.0
#tool nuget:?package=Rivulet.Sql.MySql&version=1.3.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Rivulet.Sql.MySql
MySQL-specific optimizations for Rivulet.Sql including MySqlBulkCopy and MySqlBulkLoader (LOAD DATA INFILE) integration for 10-100x faster bulk inserts.
Features
- MySqlBulkCopy: High-performance bulk inserts for in-memory data
- MySqlBulkLoader: LOAD DATA LOCAL INFILE for maximum performance with CSV data
- File-based Loading: Direct file import support
- Parallel Operations: Process multiple batches in parallel
- Custom Delimiters: Support for any field separator
- Automatic Column Mapping: Maps columns automatically
Installation
dotnet add package Rivulet.Sql.MySql
Usage
MySqlBulkCopy (In-Memory Data)
using MySqlConnector;
using Rivulet.Sql.MySql;
var rows = GetRows(); // IEnumerable<object?[]>
await rows.BulkInsertUsingMySqlBulkCopyAsync(
() => new MySqlConnection(connectionString),
"users",
columnNames: new[] { "id", "name", "email" },
options: new ParallelOptionsRivulet { MaxDegreeOfParallelism = 4 },
batchSize: 5000
);
MySqlBulkLoader (CSV Data)
var csvLines = File.ReadLines("users.csv");
await csvLines.BulkInsertUsingMySqlBulkLoaderAsync(
() => new MySqlConnection(connectionString),
"users",
columnNames: new[] { "id", "name", "email" },
options: new ParallelOptionsRivulet { MaxDegreeOfParallelism = 2 },
batchSize: 5000,
fieldSeparator: ",",
lineTerminator: "\n"
);
File-Based Bulk Loading
var csvFiles = Directory.GetFiles("data", "*.csv");
await csvFiles.BulkInsertFromFilesUsingMySqlBulkLoaderAsync(
() => new MySqlConnection(connectionString),
"users",
columnNames: new[] { "id", "name", "email" },
options: new ParallelOptionsRivulet { MaxDegreeOfParallelism = 4 },
fieldSeparator: ",",
lineTerminator: "\n"
);
Advanced: Custom Data Mapping
record User(int Id, string Name, string Email);
var users = GetUsers();
var rows = users.Select(u => new object?[] { u.Id, u.Name, u.Email });
await rows.BulkInsertUsingMySqlBulkCopyAsync(
() => new MySqlConnection(connectionString),
"users",
columnNames: new[] { "id", "name", "email" },
options: new ParallelOptionsRivulet
{
MaxDegreeOfParallelism = 4,
ErrorMode = ErrorMode.CollectAndContinue
}
);
Performance
Comparison: Standard Insert vs Bulk Operations
| Method | Rows/sec | Time for 100k rows |
|---|---|---|
| Standard Batched Insert | ~1,000 | ~100 seconds |
| MySqlBulkCopy | ~40,000+ | ~2.5 seconds |
| MySqlBulkLoader (LOAD DATA) | ~50,000+ | ~2 seconds |
| Performance Gain | 40-50x faster | 40-50x faster |
Method Selection Guide
| Method | Speed | Use Case |
|---|---|---|
| MySqlBulkCopy | Very Fast | In-memory data, typed objects |
| MySqlBulkLoader | Fastest | CSV files, text data, very large datasets |
Recommended Settings
- Batch Size: 5,000-10,000 rows per batch
- Max Parallelism: 2-4 for most workloads
- MySqlBulkLoader: Best for files > 10MB or > 50,000 rows
When to Use
✅ Use Rivulet.Sql.MySql when:
- Inserting 1,000+ rows
- Maximum performance is critical
- Using MySQL or MariaDB exclusively
- Working with CSV files
❌ Use base Rivulet.Sql when:
- Multi-database support needed
- Smaller datasets (<1,000 rows)
- Cross-platform compatibility required
Requirements
- .NET 8.0 or .NET 9.0
- MySQL 5.7 or later / MariaDB 10.2 or later
- MySqlConnector
- Important: MySQL server must have
local_infile=1enabled for MySqlBulkLoader
Configuration
To use MySqlBulkLoader, ensure your MySQL server has local file loading enabled:
SET GLOBAL local_infile = 1;
And in your connection string:
"Server=localhost;Database=mydb;User=root;Password=pass;AllowLoadLocalInfile=true"
License
MIT License - see LICENSE file for details
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. 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. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- MySqlConnector (>= 2.5.0)
- Rivulet.Sql (>= 1.3.0)
-
net9.0
- MySqlConnector (>= 2.5.0)
- Rivulet.Sql (>= 1.3.0)
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.3.0 | 150 | 12/13/2025 |
| 1.3.0-beta | 406 | 12/8/2025 |
| 1.3.0-alpha | 290 | 12/8/2025 |