KdbSharp 0.3.0

dotnet add package KdbSharp --version 0.3.0
                    
NuGet\Install-Package KdbSharp -Version 0.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="KdbSharp" Version="0.3.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="KdbSharp" Version="0.3.0" />
                    
Directory.Packages.props
<PackageReference Include="KdbSharp" />
                    
Project file
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 KdbSharp --version 0.3.0
                    
#r "nuget: KdbSharp, 0.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 KdbSharp@0.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=KdbSharp&version=0.3.0
                    
Install as a Cake Addin
#tool nuget:?package=KdbSharp&version=0.3.0
                    
Install as a Cake Tool

KdbSharp

KdbSharp NuGet Package KdbSharp NuGet Package Downloads GitHub Actions Status

GitHub Actions Build History

KdbSharp is a kdb client for .NET, providing a modern and efficient way to interact with kdb+ databases from .NET applications.

Status

This project is a work in progress. The API is subject to change. Production use is not recommended at this time.

Features

  • Connect to kdb+ databases
  • Serialize and deserialize kdb+ data types
  • Execute queries against kdb+ databases
  • Support for asynchronous operations

Installation

Install the package via NuGet:

dotnet add package KdbSharp

Usage

Basic Connection

// Connect to a kdb+ server
var connection = new KdbConnection(new KdbConnectionOptions
{
    Host = "localhost",
    Port = 5000,
    Username = "username",  // Optional
    Password = "password"   // Optional
});

// h: hopen `:localhost:5000:username:password
await connection.OpenAsync();

GetAsync - Execute Queries and Get Results

// result: h "2+3"
var result = await connection.GetAsync<long>("2 + 3");
// table: h "([] col1:1 2 3; col2:`a`b`c)"
var table = await connection.GetAsync<KTable>("([] col1:1 2 3; col2:`a`b`c)");

SetAsync - Execute Async Commands

// neg[h] "insert[`trade] (1; `AAPL; 100.5; 1000)"
await connection.SetAsync("insert[`trade] (1; `AAPL; 100.5; 1000)");
// neg[h] ".u.sub[`trade;`]"
await connection.SetAsync(".u.sub[`trade;`]");  // Subscribe to updates

Parameterized Queries with CreateCommand

// h ("{select from trade where sym=x}"; "AAPL")
var result1 = await connection.CreateCommand("{select from trade where sym=x}", "AAPL")
    .GetAsync<KTable>();

// h ("select from trade where sym=x and size>y"; "AAPL"; 500)
var result2 = connection.CreateCommand("select from trade where sym=x and size>y", "AAPL", 500L)
    .GetAsync<KTable>();

// neg[h] ("insert[`trade] (`MSFT; x)"; 150.75)
var result3 = connection.CreateCommand("insert[`trade] (`MSFT; x)", 150.75)
    .SetAsync();

Receiving Async Messages Using Subscribe Extension

// Subscribe to updates
await connection.SetAsync(".u.sub[`trade;`]");

// Use the Subscribe extension method for easier async enumeration
await foreach (var message in connection.Subscribe().WithCancellation(cancellationToken))
{
    if (message.Compressed)
    {
        message.Uncompress();
    }

    var data = message.Deserialize();
    // TODO: Process the data

    // Important: Dispose the message when done
    message.Dispose();
}

Requirements

  • .NET 6.0 or higher

Contributing

Contributions are welcome! Please see CONTRIBUTING.md for details.

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

Acknowledgements

The KMessage.Uncompress method modifications were made to functions originally found in the following repository:

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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.  net9.0 was computed.  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.
  • net6.0

    • No dependencies.

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
0.3.0 115 8/18/2025
0.2.2 149 7/14/2025
0.2.1 139 7/9/2025
0.2.0 130 7/7/2025
0.1.5 130 7/6/2025
0.1.4 75 8/27/2024
0.1.3 68 8/25/2024
0.1.2 63 8/22/2024