dasDuckDB documentation

Part of the daslang ecosystem. See also the daslang documentation and daslang.io.

dasDuckDB is the daslang binding for DuckDB (v1.5.4), an in-process analytical SQL database — and the first external provider for daslang’s _sql(...) LINQ-to-SQL machinery (daslib/sql_linq): declare a struct with [sql_table], and compile-time-checked query chains, typed CRUD, custom-type adapters, @sql_json columns, transactions and client-side [sql_function] UDFs all work against DuckDB exactly as they do against the in-tree SQLite provider. The shared provider contract is documented in the daslang repo’s PROVIDER_CONTRACT.md.

Source code: https://github.com/borisbat/dasDuckDB

Issues: https://github.com/borisbat/dasDuckDB/issues

Install

daslang utils/daspkg/main.das -- install github.com/borisbat/dasDuckDB

Or add to your project’s .das_package:

[export]
def dependencies(version : string) {
    require_package("github.com/borisbat/dasDuckDB")
}

Then run daspkg install.

Quick taste

require duckdb/duckdb_boost
require daslib/sql_linq

[sql_table(name = "Users")]
struct User {
    @sql_primary_key Id : int64
    Name : string
    Age : int
}

[export]
def main {
    with_duckdb(":memory:") $(db) {
        db |> create_table(type<User>)
        db |> insert(User(Id = int64(0), Name = "Ada", Age = 36))
        let adults = _sql(db |> select_from(type<User>) |> _where(_.Age >= 18))
    }
}