AddingDocumentation 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.
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.
Feature Flags
- better-duck-core
- better-duck-diesel
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.| Feature | Default | Description |
|---|---|---|
chrono | ✓ | chrono date/time conversions for DATE, TIME, TIMESTAMP, TIMESTAMPTZ, and INTERVAL columns. |
decimal | ✓ | rust_decimal::Decimal support for DECIMAL columns. |
json | — | Enable DuckDB’s JSON extension. |
parquet | — | Enable DuckDB’s Parquet extension. |
async | — | Tokio-based async facade (AsyncConnection, AsyncDatabase, AsyncPool) wrapping the synchronous connection in tokio::task::spawn_blocking. Requires a Tokio runtime. |
pool | — | r2d2 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. Thecccrate compiles it transparently duringcargo build. - C++ compiler. The
cccrate 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-sysships with FFI bindings already checked in for all supported platforms, so nobindgenor LLVM installation is required on the build host.
Enabling Optional Features
Specify optional features inline in yourCargo.toml dependency entry using the features key:
chrono and want to use the built-in DuckDate/DuckTime structs instead:
better-duck-diesel with chrono and r2d2: