DuckDB.NET.Data.Full
0.10.1
See the version list below for details.
dotnet add package DuckDB.NET.Data.Full --version 0.10.1
NuGet\Install-Package DuckDB.NET.Data.Full -Version 0.10.1
<PackageReference Include="DuckDB.NET.Data.Full" Version="0.10.1" />
<PackageVersion Include="DuckDB.NET.Data.Full" Version="0.10.1" />
<PackageReference Include="DuckDB.NET.Data.Full" />
paket add DuckDB.NET.Data.Full --version 0.10.1
#r "nuget: DuckDB.NET.Data.Full, 0.10.1"
#:package DuckDB.NET.Data.Full@0.10.1
#addin nuget:?package=DuckDB.NET.Data.Full&version=0.10.1
#tool nuget:?package=DuckDB.NET.Data.Full&version=0.10.1
DuckDB.NET
DuckDB bindings for C#

Usage
Support
If you encounter a bug with the library Create an Issue. Join the DuckDB .Net Channel for DuckDB.NET related topics.
Getting Started
There are two ways to work with DuckDB from C#: You can use ADO.NET Provider or use low-level bindings library for DuckDB. The ADO.NET Provider is built on top of the low-level library and is the recommended and most straightforward approach to work with DuckDB.
In both cases, there are two NuGet packages available: The Full package that includes the DuckDB native library and a managed-only library that doesn't include a native library.
| ADO.NET Provider | Includes DuckDB library | |
|---|---|---|
| DuckDB.NET.Bindings | ❌ | ❌ |
| DuckDB.NET.Bindings.Full | ❌ | ✅ |
| DuckDB.NET.Data | ✅ | ❌ |
| DuckDB.NET.Data.Full | ✅ | ✅ |
Using ADO.NET Provider
dotnet add package DuckDB.NET.Data.Full
using (var duckDBConnection = new DuckDBConnection("Data Source=file.db"))
{
duckDBConnection.Open();
using var command = duckDBConnection.CreateCommand();
command.CommandText = "CREATE TABLE integers(foo INTEGER, bar INTEGER);";
var executeNonQuery = command.ExecuteNonQuery();
command.CommandText = "INSERT INTO integers VALUES (3, 4), (5, 6), (7, 8);";
executeNonQuery = command.ExecuteNonQuery();
command.CommandText = "Select count(*) from integers";
var executeScalar = command.ExecuteScalar();
command.CommandText = "SELECT foo, bar FROM integers";
var reader = command.ExecuteReader();
PrintQueryResults(reader);
}
private static void PrintQueryResults(DbDataReader queryResult)
{
for (var index = 0; index < queryResult.FieldCount; index++)
{
var column = queryResult.GetName(index);
Console.Write($"{column} ");
}
Console.WriteLine();
while (queryResult.Read())
{
for (int ordinal = 0; ordinal < queryResult.FieldCount; ordinal++)
{
var val = queryResult.GetInt32(ordinal);
Console.Write(val);
Console.Write(" ");
}
Console.WriteLine();
}
}
Efficient data loading with Appender
Appenders are the most efficient way of loading data into DuckDB. Starting from version 0.6.1, you can use a managed Appender instead of using low-level DuckDB Api:
using var connection = new DuckDBConnection("DataSource=:memory:");
connection.Open();
using (var duckDbCommand = connection.CreateCommand())
{
var table = "CREATE TABLE AppenderTest(foo INTEGER, bar INTEGER);";
duckDbCommand.CommandText = table;
duckDbCommand.ExecuteNonQuery();
}
var rows = 10;
using (var appender = connection.CreateAppender("managedAppenderTest"))
{
for (var i = 0; i < rows; i++)
{
var row = appender.CreateRow();
row.AppendValue(i).AppendValue(i+2).EndRow();
}
}
Parameterized queries and DuckDB native types.
Starting from version 0.4.0.10, DuckDB.NET.Data supports executing parameterized queries and reading all built-in native DuckDB types. Starting from version 0.9.0 the library supports named parameters too:
using var connection = new DuckDBConnection("DataSource=:memory:");
connection.Open();
using var command = connection.CreateCommand();
//Named parameters
command.CommandText = "INSERT INTO ParametersTestKeyValue (KEY, VALUE) VALUES ($key, $value)";
command.Parameters.Add(new DuckDBParameter("key", 42));
command.Parameters.Add(new DuckDBParameter("value", "hello"));
var affectedRows = command.ExecuteNonQuery();
//Positional parameters
command.CommandText = "INSERT INTO ParametersTestKeyValue (KEY, VALUE) VALUES (?, ?)";
command.Parameters.Add(new DuckDBParameter(24));
command.Parameters.Add(new DuckDBParameter("world"));
affectedRows = command.ExecuteNonQuery();
command.CommandText = "SELECT * from integers where foo > ?;";
command.Parameters.Add(new new DuckDBParameter(3));
using var reader = command.ExecuteReader();
To read DuckDB specific native types use DuckDBDataReader.GetFieldValue<T> method. The following table shows the mapping between DuckDB native type and DuckDB.NET.Data .Net type:
| DuckDB Type | .Net Type |
|---|---|
| INTERVAL | DuckDBInterval |
| DATE | DuckDBDateOnly/DateOnly |
| TIME | DuckDBTimeOnly/TimeOnly |
| HUGEINT | BigInteger |
List, Struct, Enum, and other composite types
DuckDB.NET 0.9.2 supports reading Enum, Struct, List, Array and Map types as well as any combination of nested types.
To read an Enum, Struct or List or nested List use DuckDBDataReader.GetFieldValue<T>. For example, to read a list of doubles: DuckDBDataReader.GetFieldValue<List<double>> If the list contains null, use DuckDBDataReader.GetFieldValue<List<double?>>, otherwise an exception will be thrown when null is encountered. If you don't know whether the list contains null or not but want to skip all null values, you can use select [x for x in mylist if x IS NOT NULL] as filtered; to remove null values from the list.
Nested List can be read in a similar way: reader.GetFieldValue<List<List<int>>>
Check Tests for more examples.
Executing multiple statements in a single go.
Starting from version 0.8, you can execute multiple statements in a single go:
using var command = duckDBConnection.CreateCommand();
command.CommandText = "INSTALL 'httpfs'; Load 'httpfs';";
command.ExecuteNonQuery();
To consume multiple result sets use NextResult:
using var duckDbCommand = connection.CreateCommand();
duckDbCommand.CommandText = "Select 1; Select 2";
using var reader = duckDbCommand.ExecuteReader();
reader.Read();
var firstValue = reader.GetInt32(0);
reader.NextResult();
reader.Read();
var secondResult = reader.GetInt32(0);
Connection String Parameters
DuckDB.NET connection strings follow the standard ADO.NET syntax as a semicolon-separated list of keywords and values.
The connection string must specify the database path to the database file with either DataSource or Data Source keyword and can also contain one or more
configuration options supported by DuckDB.
For example, to limit DuckDB memory usage to 16 GB use Data Source=file.db;memory_limit=16GB. To set number of threads used by the system use Data Source=file.db;threads=8
To specify both options use: Data Source=file.db;memory_limit=16GB;threads=8
DuckDB.NET connection string keywords are case insensitive.
Dapper
You can also use Dapper to query data:
var item = duckDBConnection.Query<FooBar>("SELECT foo, bar FROM integers");
In-Memory database
For an in-memory database use Data Source=:memory: connection string. When using an in-memory database no data is persisted on disk. Every in-memory connection results in a new, isolated database so tables created
inside one in-memory connection aren't visible to another in-memory connection. If you want to create a shared in-memory database, you can use DataSource=:memory:?cache=shared connection string. Both connection strings
are exposed by the library as DuckDBConnectionStringBuilder.InMemoryDataSource and DuckDBConnectionStringBuilder.InMemorySharedDataSource respectively.
Use low-level bindings library
dotnet add package DuckDB.NET.Bindings.Full
var result = Startup.DuckDBOpen(null, out var database);
using (database)
{
result = Startup.DuckDBConnect(database, out var connection);
using (connection)
{
var queryResult = new DuckDBResult();
result = Query.DuckDBQuery(connection, "CREATE TABLE integers(foo INTEGER, bar INTEGER);", null);
result = Query.DuckDBQuery(connection, "INSERT INTO integers VALUES (3, 4), (5, 6), (7, 8);", null);
result = Query.DuckDBQuery(connection, "SELECT foo, bar FROM integers", queryResult);
PrintQueryResults(queryResult);
result = PreparedStatements.DuckDBPrepare(connection, "INSERT INTO integers VALUES (?, ?)", out var insertStatement);
using (insertStatement)
{
result = PreparedStatements.DuckDBBindInt32(insertStatement, 1, 42); // the parameter index starts counting at 1!
result = PreparedStatements.DuckDBBindInt32(insertStatement, 2, 43);
result = PreparedStatements.DuckDBExecutePrepared(insertStatement, null);
}
result = PreparedStatements.DuckDBPrepare(connection, "SELECT * FROM integers WHERE foo = ?", out var selectStatement);
using (selectStatement)
{
result = PreparedStatements.DuckDBBindInt32(selectStatement, 1, 42);
result = PreparedStatements.DuckDBExecutePrepared(selectStatement, queryResult);
}
PrintQueryResults(queryResult);
// clean up
Query.DuckDBDestroyResult(queryResult);
}
}
private static void PrintQueryResults(DuckDBResult queryResult)
{
var columnCount = Query.DuckDBColumnCount(queryResult);
for (var index = 0; index < columnCount; index++)
{
var columnName = Query.DuckDBColumnName(queryResult, index).ToManagedString(false);
Console.Write($"{columnName} ");
}
Console.WriteLine();
var rowCount = Query.DuckDBRowCount(queryResult);
for (long row = 0; row < rowCount; row++)
{
for (long column = 0; column < columnCount; column++)
{
var val = Types.DuckDBValueInt32(queryResult, column, row);
Console.Write(val);
Console.Write(" ");
}
Console.WriteLine();
}
}
Sponsors
A big thanks to AWS Open Source Software Fund for sponsoring the project!
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. 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. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- DuckDB.NET.Bindings.Full (>= 0.10.1)
- System.Runtime.CompilerServices.Unsafe (>= 6.0.0)
-
net6.0
- DuckDB.NET.Bindings.Full (>= 0.10.1)
NuGet packages (70)
Showing the top 5 NuGet packages that depend on DuckDB.NET.Data.Full:
| Package | Downloads |
|---|---|
|
Kurrent.Quack
Package Description |
|
|
UnifiedBlazor.Shared.DataAccess
UnifiedBlazor框架的DataAccess共享库 |
|
|
Kurrent.Surge.DuckDB
Package Description |
|
|
DuckDB.InteractiveExtension
DuckDB support for Polyglot Notebooks |
|
|
ShiftSoftware.ADP.SyncAgent
Package Description |
GitHub repositories (13)
Showing the top 13 popular GitHub repositories that depend on DuckDB.NET.Data.Full:
| Repository | Stars |
|---|---|
|
DapperLib/Dapper
Dapper - a simple object mapper for .Net
|
|
|
DotNetNext/SqlSugar
.Net aot ORM SqlServer ORM Mongodb ORM MySql 瀚高 Postgresql ORM DB2 Hana 高斯 Duckdb C# VB.NET Sqlite ORM Oracle ORM Mysql Orm 虚谷数据库 达梦 ORM 人大金仓 ORM 神通ORM C# ORM , C# ORM .NET ORM NET9 ORM .NET8 ORM ClickHouse ORM QuestDb ,TDengine ORM,OceanBase ORM,GaussDB ORM,Tidb ORM Object/Relational Mapping
|
|
|
dotnetcore/FreeSql
.NET aot orm, VB.NET/C# orm, Mysql/PostgreSQL/SqlServer/Oracle orm, Sqlite/Firebird/Clickhouse/DuckDB orm, 达梦/金仓/虚谷/翰高/高斯 orm, 神通 orm, 南大通用 orm, 国产 orm, TDengine orm, QuestDB orm, MsAccess orm.
|
|
|
linq2db/linq2db
Linq to database provider.
|
|
|
dotnet/interactive
.NET Interactive combines the power of .NET with many other languages to create notebooks, REPLs, and embedded coding experiences. Share code, explore data, write, and learn across your apps in ways you couldn't before.
|
|
|
mukunku/ParquetViewer
Simple Windows desktop application for viewing & querying Apache Parquet files
|
|
|
brianluft/sqlnotebook
SQL Notebook — Casual data exploration in SQL
|
|
|
Hitmasu/OpenCNPJ
API pública de busca e consulta de CNPJs do Brasil
|
|
|
J-Tech-Japan/Sekiban
Sekiban - an Opinionated Event Sourcing and CQRS Framework using C#. It can store data into Azure Cosmos DB, AWS Dynamo DB or Postgres
|
|
|
BDFFZI/Alife
一款专为桌宠方向打造的独特AIAgent。功能超全,一键安装,跨平台;全功能插件化,AI自主热修改,异常隔离;动态分层上下文,永久唯一会话,稳定可成长的长期记忆;类游戏引擎交互策略,并行流式执行器,高效实时交互;人工手搓提示词,各种小巧思,大幅降低token开销;具有极高的可玩性和成长上限,非常适合真正想入坑养AI的用户。
|
|
|
ErrorLSC/Polars.NET
.NET DataFrame Engine, powered by Arrow and Polars
|
|
|
RusselWebber/xlDuckDb
Use DuckDB within Excel with the xlDuckDb addin
|
|
|
idaholab/DeepLynx
DeepLynx Nexus is version 2 of the DeepLynx data warehouse, and acts as the central integration point for the DeepLynx data ecosystem. Nexus is a functional data catalog and digital thread tool, allowing users to track metadata from disparate sources and identify ontological and semantic connections between data. It is written in C# and React.
|
| Version | Downloads | Last Updated |
|---|---|---|
| 1.5.6.1 | 46,117 | 10/15/2026 |
| 1.5.6 | 99,194 | 9/28/2026 |
| 1.5.5 | 465,602 | 7/26/2026 |
| 1.5.3 | 433,486 | 5/24/2026 |
| 1.5.2 | 169,678 | 4/24/2026 |
| 1.5.0 | 199,496 | 3/10/2026 |
| 1.4.4 | 203,916 | 2/3/2026 |
| 1.4.4-alpha.2 | 3,623 | 12/19/2025 |
| 1.4.3 | 123,708 | 12/11/2025 |
| 1.4.1 | 220,621 | 10/13/2025 |
| 1.3.2 | 234,973 | 7/8/2025 |
| 1.3.0 | 223,432 | 6/3/2025 |
| 1.2.1 | 626,357 | 3/5/2025 |
| 1.2.1-alpha.8 | 433 | 2/19/2025 |
| 1.2.0 | 199,307 | 2/6/2025 |
| 1.1.3 | 436,412 | 11/7/2024 |
| 1.1.2.1 | 89,128 | 10/21/2024 |
| 1.1.2-alpha.5 | 234 | 10/10/2024 |
| 0.10.1 | 28,053 | 3/18/2024 |
Update to DuckDB 0.10.1.
Added support for reading TimeTz types.
Added support for reading Array types.