4 releases (2 breaking)

0.7.1 Jan 21, 2025
0.7.0 Dec 11, 2024
0.6.0 Dec 8, 2024
0.0.1 Dec 8, 2024

#272 in Authentication

Download history 374/week @ 2024-12-08 38/week @ 2024-12-15 21/week @ 2024-12-22 11/week @ 2024-12-29 23/week @ 2025-01-05 7/week @ 2025-01-12 99/week @ 2025-01-19 27/week @ 2025-01-26 88/week @ 2025-02-02 89/week @ 2025-02-09 50/week @ 2025-02-16 102/week @ 2025-02-23 211/week @ 2025-03-02

464 downloads per month

MIT license

110KB
3K SLoC

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.1"

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

Dependencies

~12–25MB
~358K SLoC