![]() |
VOOZH | about |
dotnet add package CosmoSQLClient.Core --version 6.3.1
NuGet\Install-Package CosmoSQLClient.Core -Version 6.3.1
<PackageReference Include="CosmoSQLClient.Core" Version="6.3.1" />
<PackageVersion Include="CosmoSQLClient.Core" Version="6.3.1" />Directory.Packages.props
<PackageReference Include="CosmoSQLClient.Core" />Project file
paket add CosmoSQLClient.Core --version 6.3.1
#r "nuget: CosmoSQLClient.Core, 6.3.1"
#:package CosmoSQLClient.Core@6.3.1
#addin nuget:?package=CosmoSQLClient.Core&version=6.3.1Install as a Cake Addin
#tool nuget:?package=CosmoSQLClient.Core&version=6.3.1Install as a Cake Tool
A lightweight, high-performance database client library for .NET designed for low-latency, high-throughput applications. CosmoSQLClient provides a unified interface for multiple database engines while minimizing memory allocations and binary footprint.
| Package | NuGet |
|---|---|
CosmoSQLClient.Core |
👁 NuGet |
CosmoSQLClient.MsSql |
👁 NuGet |
CosmoSQLClient.Postgres |
👁 NuGet |
CosmoSQLClient.MySql |
👁 NuGet |
CosmoSQLClient.Sqlite |
👁 NuGet |
CosmoSQLClient.CosmoKv |
👁 NuGet |
CosmoSQLClient.CosmoKvHttp |
👁 NuGet |
CosmoSQLClient.CosmoKv.Cli (dotnet tool: cosmokv) |
👁 NuGet |
CosmoSQLClient.MsSql.EntityFrameworkCore |
👁 NuGet |
CosmoSQLClient.Postgres.EntityFrameworkCore |
👁 NuGet |
CosmoSQLClient.MySql.EntityFrameworkCore |
👁 NuGet |
CosmoSQLClient.Sqlite.EntityFrameworkCore |
👁 NuGet |
System.IO.Pipelines for efficient asynchronous I/O and protocol decoding.struct-based token handlers to eliminate boxing and reduce heap pressure.IAsyncEnumerable for row-by-row processing, ideal for large datasets and reactive streams.ISqlDatabase interface across all supported engines (MSSQL, PostgreSQL, MySQL, SQLite, CosmoKv, CosmoKvHttp).| Engine | Protocol | Supported Features |
|---|---|---|
| MSSQL | TDS 7.x | Integrated Security (NTLMv2), Stored Procedures, Transactions, Named Instances |
| PostgreSQL | Frontend/Backend 3.0 | MD5/Scram-SHA-256 Auth, Transactions, Parameterized Queries |
| MySQL | MySQL Protocol 4.1+ | Standard Auth, Transactions, Parameterized Queries |
| SQLite | Local File | Native engine integration, Online Backup, Transactions |
| CosmoKv (embedded) | In-process facade over the CosmoNova engine (T-SQL parser + executor + LSM storage in one assembly) | Full T-SQL subset, MVCC transactions, online COSMOBAK backup |
| CosmoKvHttp | HTTP/JSON wire to a CosmoKvD daemon | Same T-SQL surface as CosmoKv, exposed over the network for multi-process sharing |
| CosmoKvPipes | Unix-pipes wire to a CosmoKvD daemon | Same T-SQL surface as CosmoKvHttp; faster than HTTP for co-located processes |
Starting at v6.0, CosmoSQLClient.CosmoKv is a thin ISqlDatabase facade (~250 LOC). The T-SQL engine that used to live in this package was extracted into the standalone CosmoNova package (storage + engine in one assembly); this driver depends on it and exposes the connection API via CosmoKvConnection / CosmoKvConfiguration.
using CosmoSQLClient.CosmoKv;
await using var conn = await CosmoKvConnection.OpenAsync(
new CosmoKvConfiguration { DataSource = "/var/lib/myapp" });
await conn.ExecuteAsync("CREATE TABLE users (id BIGINT IDENTITY PRIMARY KEY, name VARCHAR(64));");
await conn.ExecuteAsync(
"INSERT INTO users (name) VALUES (@n);",
new List<SqlParameter> { SqlParameter.Named("@n", SqlValue.From("Ada")) });
var rows = await conn.QueryAsync("SELECT * FROM users;");
The supported T-SQL surface (as of CosmoNova 1.0+) is documented in the CosmoNova README. Highlights: full DDL (CREATE TABLE/INDEX with IF NOT EXISTS), JOIN (INNER/LEFT/RIGHT/FULL/CROSS), GROUP BY + GROUPING SETS, PIVOT/UNPIVOT, CTEs, windowed functions, IDENTITY, UNIQUE/PRIMARY KEY constraints, OUTPUT clauses, MERGE, scalar UDFs, stored procedures, triggers (subset), OPTION (RECOMPILE|FORCE ORDER|MAXDOP n) hints, hash join + cost-based join reordering. Embedded benchmarks show 32–60× faster than SQL Server 2025 on the same T-SQL.
Exceptions thrown by the engine (SqlTransactionConflictException, UniqueConstraintViolationException) live in the CosmoNova.Sql namespace as of v6.0. If your code catches them, add using CosmoNova.Sql; where needed.
Add the package for your specific database engine:
dotnet add package CosmoSQLClient.MsSql
dotnet add package CosmoSQLClient.Postgres
dotnet add package CosmoSQLClient.MySql
dotnet add package CosmoSQLClient.Sqlite
dotnet add package CosmoSQLClient.CosmoKv # embedded T-SQL on CosmoKv
dotnet add package CosmoSQLClient.CosmoKvHttp # T-SQL over HTTP to CosmoKvD
For Entity Framework Core integration, install the matching bridge package for your provider:
dotnet add package CosmoSQLClient.MsSql.EntityFrameworkCore
dotnet add package CosmoSQLClient.Postgres.EntityFrameworkCore
dotnet add package CosmoSQLClient.MySql.EntityFrameworkCore
dotnet add package CosmoSQLClient.Sqlite.EntityFrameworkCore
| Provider package | EF Core bridge package | Extension method |
|---|---|---|
CosmoSQLClient.MsSql |
CosmoSQLClient.MsSql.EntityFrameworkCore |
UseCosmoSqlServer(...) |
CosmoSQLClient.Postgres |
CosmoSQLClient.Postgres.EntityFrameworkCore |
UseCosmoPostgres(...) |
CosmoSQLClient.MySql |
CosmoSQLClient.MySql.EntityFrameworkCore |
UseCosmoMySql(...) |
CosmoSQLClient.Sqlite |
CosmoSQLClient.Sqlite.EntityFrameworkCore |
UseCosmoSqlite(...) |
using CosmoSQLClient.MsSql;
var connStr = "Server=localhost;Database=Sales;User Id=sa;Password=your_password;";
await using var conn = await MsSqlConnection.OpenAsync(connStr);
await using var cmd = conn.CreateCommand("SELECT TOP 10 * FROM Invoices");
await using var reader = await cmd.ExecuteReaderAsync();
while (await reader.ReadAsync())
{
var total = reader.GetDecimal("TotalAmount");
Console.WriteLine($"Invoice Total: {total}");
}
using CosmoSQLClient.CosmoKv;
using CosmoSQLClient.Core;
await using var conn = await CosmoKvConnection.OpenAsync(
new CosmoKvConfiguration { DataSource = "/var/lib/app/db" });
await conn.ExecuteAsync("""
CREATE TABLE IF NOT EXISTS Users (
Id BIGINT IDENTITY PRIMARY KEY,
Email NVARCHAR(256) NOT NULL,
CreatedAt DATETIME2 NOT NULL DEFAULT GETUTCDATE())
""");
// INSERT … OUTPUT returns the just-allocated IDENTITY.
var inserted = await conn.QueryAsync(
"INSERT INTO Users (Email) OUTPUT INSERTED.Id VALUES (@e)",
new[] { SqlParameter.Named("@e", SqlValue.From("alice@d.com")) });
long newId = inserted[0]["Id"].AsInt() ?? 0;
// INNER JOIN with qualified column refs.
var rows = await conn.QueryAsync(
"SELECT u.Email FROM Users u JOIN Mailboxes m ON m.UserId = u.Id");
Rows are yielded as they arrive from the socket, ensuring the full result set is never buffered in memory.
await foreach (var row in conn.Advanced.QueryStreamAsync("SELECT * FROM LargeTable"))
{
var id = row["Id"].AsInt32();
// Process one row at a time
}
CosmoSQLClient can be used as the underlying DbConnection for the standard EF Core relational providers. Install the matching EF Core bridge package, then configure your DbContext with the Cosmo-specific extension for that database.
using Microsoft.EntityFrameworkCore;
services.AddDbContext<AppDbContext>(options =>
options.UseCosmoSqlServer("Server=localhost;Database=Sales;User Id=sa;Password=your_password;TrustServerCertificate=True;"));
services.AddDbContext<AppDbContext>(options =>
options.UseCosmoPostgres("Host=localhost;Database=Sales;User Id=postgres;Password=your_password;"));
services.AddDbContext<AppDbContext>(options =>
options.UseCosmoMySql(
"Host=localhost;Database=Sales;User Id=root;Password=your_password;",
new MySqlServerVersion(new Version(8, 0, 0))));
services.AddDbContext<AppDbContext>(options =>
options.UseCosmoSqlite("Data Source=sales.db"));
cosmokvA sqlite3-style shell for CosmoKv embedded databases — REPL, one-shot SQL, stdin scripts, and four output formats. Ships as a dotnet global tool.
dotnet tool install -g CosmoSQLClient.CosmoKv.Cli
cosmokv ./mydb # REPL
cosmokv ./mydb "SELECT * FROM Users" # one-shot
cat schema.sql | cosmokv ./mydb - # stdin script
cosmokv --format=json ./mydb "SELECT * FROM Users" # JSON output
REPL dot-commands cover the usual introspection surface (.tables, .schema [TABLE], .indexes [TABLE], .dump, .format FMT, .quit). Full reference: .
The introspection used by .schema / .dump is also available programmatically from v2.5 — CosmoKvConnection.GetTableNames(), GetTableScript(name), GetIndexScriptsForTable(name), ScriptSchema() — so you can build your own dump/backup tooling without going through the CLI.
CosmoSQLClient implements a generic protocol decoder (ProcessTokensAsync) using struct handlers. This architecture ensures:
SqlRow and SqlValue types are never cast to object during decoding.CosmoSQLClient avoids heavy dependencies like Azure.Identity, MSAL, or Microsoft.Data.SqlClient.SNI.
| Library | Published Footprint |
|---|---|
| CosmoSQLClient.MsSql | ~207 KB |
| Microsoft.Data.SqlClient | ~17 MB+ |
SqlValue is the universal cell type returned by advanced query methods. It wraps the raw wire value and provides typed accessors:
SqlValue Accessor |
.NET Type |
|---|---|
AsInt32() / AsInt64() |
int / long |
AsString() |
string |
AsDecimal() |
decimal |
AsDouble() / AsFloat() |
double / float |
AsBoolean() |
bool |
AsDateTime() / AsDateTimeOffset() |
DateTime / DateTimeOffset |
AsGuid() |
Guid |
AsBytes() |
byte[] |
IsNull |
bool |
Supports native NTLMv2 authentication for Windows/Linux environments without external dependencies.
var connStr = "Server=myserver;Integrated Security=SSPI;Trust Server Certificate=true;";
await using var conn = await MsSqlConnection.OpenAsync(connStr);
Stream query results directly to a PipeWriter or Stream as JSON with zero intermediate allocations.
await conn.Advanced.QueryJsonStreamAsync(
"SELECT * FROM Users",
pipeWriter,
format: JsonOutputFormat.Array);
var result = await conn.Advanced.ExecuteProcAsync("GetCustomerInvoices", new {
CustomerId = 123,
Year = 2024
});
Licensed under the .
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 was computed. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 was computed. |
| .NET Framework | net461 net461 was computed. net462 net462 was computed. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 5 NuGet packages that depend on CosmoSQLClient.Core:
| Package | Downloads |
|---|---|
|
CosmoSQLClient.MsSql
Microsoft SQL Server driver for CosmoSQLClient — TDS 7.4 wire protocol from scratch using System.IO.Pipelines. Supports TLS, Windows/SQL auth, stored procedures and connection pooling. |
|
|
CosmoSQLClient.Sqlite
SQLite driver for CosmoSQLClient — wraps Microsoft.Data.Sqlite behind the unified ISqlDatabase interface with connection pooling support. |
|
|
CosmoSQLClient.Postgres
PostgreSQL driver for CosmoSQLClient — PostgreSQL v3 wire protocol using System.IO.Pipelines. Supports SCRAM-SHA-256 auth, TLS and connection pooling. |
|
|
CosmoSQLClient.MySql
MySQL driver for CosmoSQLClient — MySQL v10 wire protocol using System.IO.Pipelines. Supports mysql_native_password, caching_sha2_password auth and connection pooling. |
|
|
CosmoSQLClient.CosmoKv
CosmoKv driver for CosmoSQLClient — runs a T-SQL subset directly on top of an embedded CosmoKv LSM-tree store. Single-process, transactional, schema-on-write. |
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 6.3.1 | 278 | 6/16/2026 |
| 6.3.0 | 286 | 6/16/2026 |
| 6.2.9 | 350 | 6/14/2026 |
| 6.2.8 | 417 | 6/14/2026 |
| 6.2.7 | 1,173 | 5/29/2026 |
| 6.2.6 | 416 | 5/29/2026 |
| 6.2.5 | 373 | 5/28/2026 |
| 6.2.4 | 375 | 5/28/2026 |
| 6.2.3 | 384 | 5/28/2026 |
| 6.2.2 | 373 | 5/28/2026 |
| 6.2.1 | 368 | 5/28/2026 |
| 6.2.0 | 363 | 5/26/2026 |
| 6.1.9 | 370 | 5/26/2026 |
| 6.1.8 | 371 | 5/26/2026 |
| 6.1.7 | 366 | 5/26/2026 |
| 6.1.6 | 411 | 5/26/2026 |
| 6.1.5 | 359 | 5/26/2026 |
| 6.1.4 | 360 | 5/26/2026 |
| 6.1.3 | 363 | 5/26/2026 |
| 6.1.2 | 373 | 5/26/2026 |