![]() |
VOOZH | about |
dotnet add package DuckDbSharp --version 1.5.0
NuGet\Install-Package DuckDbSharp -Version 1.5.0
<PackageReference Include="DuckDbSharp" Version="1.5.0" />
<PackageVersion Include="DuckDbSharp" Version="1.5.0" />Directory.Packages.props
<PackageReference Include="DuckDbSharp" />Project file
paket add DuckDbSharp --version 1.5.0
#r "nuget: DuckDbSharp, 1.5.0"
#:package DuckDbSharp@1.5.0
#addin nuget:?package=DuckDbSharp&version=1.5.0Install as a Cake Addin
#tool nuget:?package=DuckDbSharp&version=1.5.0Install as a Cake Tool
DuckDbSharp is a bidirectional interoperability layer between DuckDB and .NET.
Features
[Flags] enumsIEnumerable<>Notes:
-- my_query.sql
SELECT
42 AS column1,
[1, 2, 3] AS column2,
[{a: 1, b: 2}] as column3
foreach (var user in db.ExecuteQuery_my_query())
{
// "user" has an auto-generated type with all the fields and sub-fields of the SQL query above.
}
See detailed instructions below.
using var db = ThreadSafeTypedDuckDbConnection.CreateInMemory();
foreach (var user in db.Execute<User>("select * from user"))
{
}
You can also use value tuples (Execute<(string A, int B)>("select 'a', 42")), but keep in mind that only column order matters, since tuple member names are erased at runtime.
[DuckDbFunction]
public static IEnumerable<User> GetUsers(string country) { /*...*/ }
SELECT * FROM GetUsers('US')
DuckDbSharp.sql queries you want to be able to call from .NET
ReturnType query_name(paramtype1, paramtype2).sqlReturnType is not specified, a type will be automatically generated based on the SQL schema of the result.string or long). Otherwise, parens are unnecessary.GenerateCSharpTypes as shown in the example, and run.TypedDuckDbConnectionBase (one for each query).Time to read ~100,000 rows of Northwind customers. In all 4 cases, the final result is a List<Customer>.
| Library | Mean | Error | StdDev | Description
|------------------------------ |---------:|--------:|--------:|--------------
| DuckDbSharp (this project) | 145.4 ms | 2.63 ms | 2.46 ms |SELECT * FROM customer
| DuckDB.NET + Dapper | 177.2 ms | 2.88 ms | 2.69 ms | SELECT * FROM customer
| Protobuf-net | 131.3 ms | 2.52 ms | 2.81 ms | Deserialize from MemoryStream of protos
| Newtonsoft JSON | 241.7 ms | 2.93 ms | 2.60 ms | Deserialize from MemoryStream of JSON
Note: while protobuf-net is slightly faster, its use cases is very different (serialization/deserialization only, with no query support)
[DuckDbInclude] and [DuckDbIgnore] always take the precedence over other rules. In their absence, [ProtoMember] from protobuf-net is also taken into account. Otherwise, only public fields and properties are taken into account.[DuckDbSerializeAs(typeof(string))] or [DuckDbSerializeAs(typeof(int))] (or whatever their underlying type is).[Flags] enums are always serialized as structs of booleans, one for each bit.[DuckDbDefaultValueIsNullish] can be applied to structs, and it means that default(SomeStruct) should be represented as NULL in DuckDB.DuckDbUtils.QueryParquet<T>() and DuckDbUtils.WriteParquet<T>() to directly read/write .parquet files (no database required).| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 net8.0 is compatible. 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 was computed. 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. |
This package is not used by any NuGet packages.
Showing the top 1 popular GitHub repositories that depend on DuckDbSharp:
| Repository | Stars |
|---|---|
|
alnkesq/AppViewLite
A Bluesky appview focused on low resource consumption
|