#database-client #tokio #gel #async-client #transaction #run-time #await

gel-tokio

Gel database client implementation for tokio. Formerly published as gel-tokio

1 unstable release

new 0.5.1 Jan 14, 2025

#2105 in Database interfaces

MIT/Apache

265KB
6K SLoC

Gel Rust Binding for Tokio

Async client for the Gel database, using Tokio runtime.

Example Usage

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    let conn = gel_tokio::create_client().await?;
    let val = conn.query_required_single::<i64, _>(
        "SELECT 7*8",
        &(),
    ).await?;
    println!("7*8 is: {}", val);
    Ok(())
}

Transaction Example

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    let conn = gel_tokio::create_client().await?;
    let val = conn.transaction(|mut transaction| async move {
        transaction.query_required_single::<i64, _>(
            "SELECT (UPDATE Counter SET { value := .value + 1}).value LIMIT 1",
            &()
        ).await
    }).await?;
    println!("Counter: {val}");
    Ok(())
}

More examples on github

License

Licensed under either of

at your option.

Dependencies

~19–32MB
~600K SLoC