This is the skuirrels/DuckDB.NET
fork of the upstream DuckDB.NET project.
It provides preview packages containing the cutting-edge performance work while
the corresponding upstream pull requests are reviewed and released.
dotnet add package Skuirrels.DuckDB.NET.Data.Full --version 1.5.4-preview.2The fork packages retain the official DuckDB.NET.Data namespaces and assembly
names. Do not reference this package and the official DuckDB.NET.Data.Full
package in the same dependency graph.
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();
}
}To connect to MotherDuck:
using var duckDBConnection = new DuckDBConnection("DataSource=md:{your_database}?motherduck_token=ey...");If you want to build DuckDB extensions with C#, see Giorgi/DuckDB.ExtensionKit.
When debugging your project that uses DuckDB.NET library, you may get the following error: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. The error happens due to debugger interaction with the native memory. For a workaround check out Debugger Options mess up debugging session during Marshalling
Documentation is available at https://duckdb.net
For a fork-specific problem, create an issue in this fork.
For upstream DuckDB.NET support, use the upstream issue tracker.
You can also join the DuckDB dotnet channel for DuckDB.NET-related topics.
A big thanks to DuckDB Labs and AWS Open Source Software Fund for sponsoring the project!

