Gleam bindings for DuckDB on the Erlang runtime.
Install:
gleam add duckling@1Run:
import duckling
import duckling/param
import gleam/dict
import gleam/dynamic/decode
import gleam/result
pub fn main() {
use db <- duckling.with_database("foo.duckdb", dict.new())
use conn <- duckling.with_connection(db)
use res <- result.try(duckling.query(
"SELECT ? + ?",
with: [param.int(1), param.int(2)],
expecting: duckling.TupleDecoder(decode.at([0], decode.int)),
on: conn,
))
assert res == [3]
}Further documentation can be found at https://hexdocs.pm/duckling.
This library currently implements the full capabilities exposed by the educkdb bindings.
- Query API
- [-] Bound Parameters 1
- Positional Parameters
- Named Parameters
- Blob type
- Boolean type
- Date type
- Decimal type
- Double type
- Enum type
- Float type
- Int128 type
- Int16 type
- Int64 type
- Int8 type
- Int32 type
- Interval type
- Json type
- List type
- Map type
- Struct type
- Time type
- Timestamp type
- TimestampMs type
- TimestampNs type
- TimestampS type
- UInt128 type
- UInt16 type
- UInt64 type
- UInt8 type
- UInt32 type
- Uuid type
- Varchar type
- Iterator / Chunk API
- Logical Column Type API 2
- Appender API
- Erlang Backend (educkdb)
- Improved compilation times
| duckling | educkdb | DuckDB |
|---|---|---|
| 1.0.0 | 0.9.10 | 1.3.1 |
- If your datatype does not have a native bound parameter you may be able to work around the missing type by passing a varchar then casting in your query. DuckDB declares VARCHAR is a "universal target". Values can always be cast into and out of VARCHAR losslessly. See [here](https://duckdb.org/docs/stable/sql/data_types/typecasting#varchar) for more details.
- Users of DuckDB will be familiar with the Logical Data types. Logical data types are what are most closely what is used in SQL when casting or creating a table. These are the qualified versions container types. Unfortunately educkdb does not expose the logical types, only the base types. We will likely have to implement our own erlang NIF before we can expose these. The logical data type API will be required for adding parameter binding for the more complex and composite data types as well.
