Crates.io | async-duckdb |
lib.rs | async-duckdb |
version | |
source | src |
created_at | 2024-07-26 00:15:56.720717+00 |
updated_at | 2025-03-12 18:23:42.463664+00 |
description | A library for working with duckdb asynchronously |
homepage | |
repository | https://github.com/jessekrubin/async-duckdb |
max_upload_size | |
id | 1315583 |
Cargo.toml error: | TOML parse error at line 21, column 1 | 21 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
NOTE: THIS IS A SED/AWK-ed VERSION OF RYAN FOWLER'S async-sqlite
CRATE (https://github.com/ryanfowler/async-sqlite); the following readme is a crude adaptation of the original async-sqlite
readme.
NOTE: POOLS CAN ONLY BE USED WITH access_mode='read_only'
https://duckdb.org/docs/connect/concurrency.html#handling-concurrency
NOTE: Providing a custom configuration to a client/pool is done via a closure that returns a duckdb-configuration struct.
A library to interact with duckdb from an async context.
This library is tested on both tokio and async_std, however it should be compatible with all async runtimes.
Add async-duckdb
to your "dependencies" in your Cargo.toml file.
This can be done by running the command:
cargo add async-duckdb
A Client
represents a single background duckdb connection that can be called
concurrently from any thread in your program.
To create a duckdb client and run a query:
use async_duckdb::{ClientBuilder};
let client = ClientBuilder::new()
.path("/path/to/db.duckdb")
.open()
.await?;
let value: String = client.conn(|conn| {
conn.query_row("SELECT val FROM testing WHERE id=?", [1], |row| row.get(0))
}).await?;
println!("Value is: {value}");
A Pool
represents a collection of background duckdb3 connections that can be
called concurrently from any thread in your program.
To create a duckdb pool and run a query:
use async_duckdb::{PoolBuilder};
let pool = PoolBuilder::new()
.path("/path/to/db.duckdb")
.open()
.await?;
let value: String = pool.conn(|conn| {
conn.query_row("SELECT val FROM testing WHERE id=?", [1], |row| row.get(0))
}).await?;
println!("Value is: {value}");
This library tries to export almost all features that the underlying duckdb library contains.
A notable difference is that the bundled
feature is enabled by default,
but can be disabled with the following line in your Cargo.toml:
async-duckdb = { version = "*", default-features = false }