trino-rust-client

Crates.iotrino-rust-client
lib.rstrino-rust-client
version
sourcesrc
created_at2024-12-08 17:02:24.967515
updated_at2024-12-11 18:32:09.876113
descriptionA trino client library
homepagehttps://github.com/nudibranches-tech/trino-rust-client
repositoryhttps://github.com/nudibranches-tech/trino-rust-client
max_upload_size
id1476444
Cargo.toml error:TOML parse error at line 18, column 1 | 18 | 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`
size0
(harksin)

documentation

https://docs.rs/trino-rust-client

README

Trino rust client

A trino client library written in rust.

This project have been forked on 08/12/24 from the great : prusto made by @nooberfsh.

Fork rationale :

  • Remove presto support
  • Add advanced trino features.
  • Rename things as "trino"

Features

authn:

  • Basic Auth
  • Jwt Auth

Installation

# Cargo.toml
[dependencies]
trino-rust-client = "0.7.0"

Example

Basic example

use trino_rust_client::{ClientBuilder, Trino};

#[derive(Trino, Debug)]
struct Foo {
    a: i64,
    b: f64,
    c: String,
}

#[tokio::main]
async fn main() {
    let cli = ClientBuilder::new("user", "localhost")
        .port(8090)
        .catalog("catalog")
        .build()
        .unwrap();

    let sql = "select 1 as a, cast(1.1 as double) as b, 'bar' as c ";

    let data = cli.get_all::<Foo>(sql.into()).await.unwrap().into_vec();

    for r in data {
        println!("{:?}", r)
    }
}

Https & Jwt example

use trino_rust_client::{ClientBuilder, Trino};

#[derive(Trino, Debug)]
struct Foo {
    a: i64,
    b: f64,
    c: String,
}

#[tokio::main]
async fn main() {
    let auth = Auth::Jwt("your access token");

    let cli = ClientBuilder::new("user", "localhost")
        .port(8443)
        .secure(true)
        .auth(auth)
        .catalog("catalog")
        .build()
        .unwrap();

    let sql = "select 1 as a, cast(1.1 as double) as b, 'bar' as c ";

    let data = cli.get_all::<Foo>(sql.into()).await.unwrap().into_vec();

    for r in data {
        println!("{:?}", r)
    }
}

License

MIT

Commit count: 202

cargo fmt