Available

amalgame-duckdb

Embedded analytic (OLAP) database, vectorized execution, direct CSV reads.

amc package add duckdb GitHub ↗ ← Back to the ecosystem

Overview

DuckDB is the SQLite of analytics: embedded, server-less, but built for OLAP queries — vectorized execution, parallelism across all cores, direct CSV reads. The package ships DuckDB 1.5.2 and reuses the methods of the sqlite package. You need a C++17 compiler. Compiling DuckDB is slow (about 15 minutes), but it happens only once, when the package is installed.

Features

  • ✓Vectorized, columnar execution, built for aggregations
  • ✓Direct CSV file reads with read_csv
  • ✓SQL close to the PostgreSQL dialect
  • ✓API aligned with the sqlite package: Exec, QueryAll, ? parameters, transactions
  • ✓DuckDB under the MIT licence, binding under Apache-2.0

Planned

  • ◐Parquet loading helper (DuckDB.LoadParquet)
  • ◐Typed column accessors: today every cell comes back as text
  • ◐Streamed results for queries that do not fit in memory
  • ◐BLOBs and named parameters

Example

Minimal usage example — copy-paste runnable after install.

import Amalgame.Database.DuckDB

public class Program {
    public static void Main() {
        let db = DuckDB.Open("analytics.duckdb")
        if (!DuckDB.IsOpen(db)) {
            Console.WriteLine("open failed: " + DuckDB.LastError(db))
            return
        }
        DuckDB.Exec(db, "CREATE OR REPLACE TABLE sales AS SELECT * FROM read_csv('sales.csv')")

        let top = DuckDB.QueryAll(db, "SELECT region, SUM(amount) FROM sales GROUP BY region ORDER BY region")
        for row in top {
            Console.WriteLine(row.Get(0) + " : " + row.Get(1))
        }
        DuckDB.Close(db)
    }
}

At a glance

Related packages