14 releases

0.3.9 Nov 25, 2021
0.3.8 Aug 2, 2021
0.3.7 Jul 14, 2021
0.2.3 May 21, 2021
0.1.0 Apr 23, 2021

#96 in Database implementations

Download history 31/week @ 2021-08-15 4/week @ 2021-08-22 3/week @ 2021-09-05 5/week @ 2021-09-12 19/week @ 2021-09-19 14/week @ 2021-09-26 1/week @ 2021-10-03 30/week @ 2021-10-10 2/week @ 2021-10-17 4/week @ 2021-10-24 1/week @ 2021-10-31 15/week @ 2021-11-07 1/week @ 2021-11-14 21/week @ 2021-11-21 20/week @ 2021-11-28

57 downloads per month
Used in bailongma

AGPL-3.0

175KB
4K SLoC

libtaos - yet another TDengine connector for Rust

Crates.io Crates.io

Thanks @songtianyi for libtdengine - a rust bindings project for TDengine.

It's an new design for TDengine rust client based on C interface or the REST API. It'll will provide Rust-like APIs and all rust things (like async/stream/iterators and others).

Dependencies

if you use the default features, it'll depend on:

  • TDengine Client library and headers.
  • clang because bindgen will requires the clang AST library.

Fetures

In-design features:

  • API for both C interface
  • REST API support by feature rest.
  • r2d2 Pool support by feature r2d2
  • Iterators for fields fetching
  • Stream support
  • Subscribe support

Build and test

cargo build
cargo test

test will use default TDengine user and password on localhost (TDengine default).

Set variables if it's not default:

  • TEST_TAOS_IP
  • TEST_TAOS_PORT
  • TEST_TAOS_USER
  • TEST_TAOS_PASS
  • TEST_TAOS_DB

Usage

For default C-based client API, set in Cargo.toml

[dependencies]
libtaos = "*"

For r2d2 support:

[dependencies]
libtaos = { version = "*", features = ["r2d2"] }

For REST client:

[dependencies]
libtaos = { version = "*", features = ["rest"] }

There's a demo app in examples directory, looks like this:

// ...
#[tokio::main]
async fn main() -> Result<(), Error> {
    init();
    let taos = taos_connect()?;

    assert_eq!(
        taos.query("drop database if exists demo").await.is_ok(),
        true
    );
    assert_eq!(taos.query("create database demo").await.is_ok(), true);
    assert_eq!(taos.query("use demo").await.is_ok(), true);
    assert_eq!(
        taos.query("create table m1 (ts timestamp, speed int)")
            .await
            .is_ok(),
        true
    );

    for i in 0..10i32 {
        assert_eq!(
            taos.query(format!("insert into m1 values (now+{}s, {})", i, i).as_str())
                .await
                .is_ok(),
            true
        );
    }
    let rows = taos.query("select * from m1").await?;

    println!("{}", rows.column_meta.into_iter().map(|col| col.name).join(","));
    for row in rows.rows {
        println!("{}", row.into_iter().join(","));
    }
    Ok(())
}

Contribution

Welcome for all contributions.

License

Keep same with TDengine.

Dependencies

~3–7.5MB
~157K SLoC

5a