Skip to content

About

Experimental .NET Core binding for chDB library

Resources

Stars

19 stars

Watchers

2 watching

Forks

Repository files navigation

chdb

A .NET Core binding for chdb library.

GitHub License example workflow NuGet Version NuGet Downloads

Architecture

Usage

Running on platforms: linux, osx, windows, and architectures: x64, arm64.

Note for windows users - there is no windows build in sight, but you can still use it in WSL.

# install the package to your project
dotnet add package chdb

The native library comes in a package per platform (chdb-linux-x64, chdb-linux-arm64, chdb-osx-x64, chdb-osx-arm64), which NuGet picks from the chdb package's runtime.json only when the project names a runtime identifier: set <RuntimeIdentifier>linux-x64</RuntimeIdentifier> (or osx-arm64, ...) in the project, or pass -r <rid> to dotnet build/run/publish.

Then you can use it in your code like this:

using ChDb;

var result = ChDb.Query("select version()");
Console.WriteLine(result.Text);
// 26.11.1.1
var s = new Session();
var result = s.Query("select * from system.formats where is_output = 1", "PrettyCompact");
// ┌─name───────────────────────────────────────┬─is_input─┬─is_output─┬─supports_parallel_parsing─┬─supports_parallel_formatting─┐
// │ Prometheus                                 │        0 │         1 │                         0 │                            0 │
// │ PostgreSQLWire                             │        0 │         1 │                         0 │                            0 │
// │ MySQLWire                                  │        0 │         1 │                         0 │                            0 │
// │ JSONEachRowWithProgress                    │        0 │         1 │                         0 │                            0 │
// │ ODBCDriver2                                │        0 │         1 │                         0 │                            0 │
// ...
var result = s.Query("DESCRIBE s3('https://datasets-documentation.s3.eu-west-3.amazonaws.com/house_parquet/house_0.parquet')");
Console.WriteLine(result.Text);

or use it right in F# interactive with dotnet fsi:

#r "nuget: chdb"

open ChDb

// print out result in the TabSeparated format by default
let result = ChDb.Query "select version()"
printfn "%s" result.Text
// or save result to a text or binary file in any supported format
let result = ChDb.Query("select * from system.formats where is_output = 1", "CSVWithNames")
System.IO.File.WriteAllBytes("supported_formats.csv", result.Buf)

chdb-tool

NuGet Version NuGet Downloads

This is a dotnet tool, running chdb library. Probably you better served using the clickhouse client and run clickhouse local, but maybe it is more useful in some cases.

Installation

Requires .NET SDK 10.0 or later.

dotnet tool install --global chdb-tool

OS supported: linux, osx ARCH supported: x64, arm64

Usage

Try any of this commands lines to see which output you get.

chdb
chdb --version
chdb --help
chdb "select version()"
chdb "select * from system.formats where is_output = 1" PrettyCompact

Build

# downloads the library of the host platform, in the ChdbVersion of Directory.Build.props, into lib/<platform>/
./update_libchdb.sh
# optionally specify explicit version and platform
./update_libchdb.sh v26.11.0-rc.2 linux-x86_64
dotnet build -c Release
dotnet test -c Release
dotnet pack src/chdb/chdb.csproj -c Release
# native packages, one per runtime identifier (expects lib/<platform>/libchdb.so)
dotnet pack src/chdb-runtime/chdb-runtime.csproj -c Release -p:RID=linux-x64
dotnet nuget add source ./nupkg --name chdb
dotnet tool update -g chdb-tool
chdb --version

Authors

About

Experimental .NET Core binding for chDB library

Resources

Stars

19 stars

Watchers

2 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages