Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/nimdeveloper/better-duck/llms.txt

Use this file to discover all available pages before exploring further.

Adding better-duck to a Rust project is a single Cargo.toml edit — no system DuckDB library, no pkg-config, and no LLVM required. DuckDB is compiled from a vendored C++ source archive inside better-duck-sys the first time you build, then cached by Cargo like any other compiled dependency. The minimum supported Rust version is 1.96.

Adding Dependencies

Choose the crates you need and paste the snippet below into your [dependencies] table. Use better-duck-core alone for direct SQL access, or add better-duck-diesel when you want the full Diesel 2.3 query DSL and migration support.
[dependencies]
# Core only — direct SQL access, full type system, async, pool, and UDF support
better-duck-core = "0.1.0-beta.4"

# Or: Core + Diesel ORM backend
better-duck-core   = "0.1.0-beta.4"
better-duck-diesel = "0.1.0-beta.4"
You can also use the Cargo CLI to add a crate:
cargo add better-duck-core --version 0.1.0-beta.4
Cargo’s default SemVer resolver excludes pre-release versions. A version requirement written as "0.1" will never resolve to 0.1.0-beta.4. You must write the exact pre-release string — "0.1.0-beta.4" — or pass --version 0.1.0-beta.4 to cargo add. This is standard Cargo behaviour for any -alpha/-beta/-rc suffix.

Feature Flags

better-duck-core ships with two features enabled by default — chrono date/time support and rust_decimal support — and several opt-in features for richer integrations. Compiling DuckDB from the vendored source archive is unconditional in 0.1.0-beta.4 and requires no feature flag.
FeatureDefaultDescription
chronochrono date/time conversions for DATE, TIME, TIMESTAMP, TIMESTAMPTZ, and INTERVAL columns.
decimalrust_decimal::Decimal support for DECIMAL columns.
jsonEnable DuckDB’s JSON extension.
parquetEnable DuckDB’s Parquet extension.
asyncTokio-based async facade (AsyncConnection, AsyncDatabase, AsyncPool) wrapping the synchronous connection in tokio::task::spawn_blocking. Requires a Tokio runtime.
poolr2d2 connection pool backed by a shared Database handle, so all pooled connections share one database instance.
udf#[duckdb_scalar] and #[duckdb_table_function] attribute macros for registering plain Rust functions as DuckDB scalar or table functions.

Build Requirements

better-duck is designed to have minimal build-time requirements for the common case:
  • No system DuckDB installation. DuckDB is bundled as a vendored C++ source archive inside better-duck-sys. The cc crate compiles it transparently during cargo build.
  • C++ compiler. The cc crate requires a C++ compiler to be present on the build host (e.g. gcc/g++ on Linux, Xcode Command Line Tools on macOS, MSVC or MinGW on Windows). This is almost always already present in a Rust development environment.
  • Rust 1.96 or later (MSRV). The entire workspace sets rust-version = "1.96" in [workspace.package]. Earlier toolchains will be rejected by Cargo.
  • Pre-generated FFI bindings. better-duck-sys ships with FFI bindings already checked in for all supported platforms, so no bindgen or LLVM installation is required on the build host.

Enabling Optional Features

Specify optional features inline in your Cargo.toml dependency entry using the features key:
[dependencies]
# Enable async support, the r2d2 connection pool, and user-defined functions
better-duck-core = { version = "0.1.0-beta.4", features = ["async", "pool", "udf"] }
To enable all features at once (useful for exploring the full API in a scratch project):
[dependencies]
better-duck-core = { version = "0.1.0-beta.4", features = ["async", "pool", "udf", "json", "parquet"] }
To turn off a default feature — for example, if you do not need chrono and want to use the built-in DuckDate/DuckTime structs instead:
[dependencies]
better-duck-core = { version = "0.1.0-beta.4", default-features = false, features = ["decimal"] }
For better-duck-diesel with chrono and r2d2:
[dependencies]
better-duck-core   = "0.1.0-beta.4"
better-duck-diesel = { version = "0.1.0-beta.4", features = ["chrono", "r2d2"] }

Build docs developers (and LLMs) love