Crates.io | libtaos |
lib.rs | libtaos |
version | 0.4.5 |
source | src |
created_at | 2021-04-23 03:23:19.840471 |
updated_at | 2023-01-10 02:44:52.194192 |
description | TDengine Client for Rust |
homepage | https://github.com/taosdata/libtaos-rs |
repository | https://github.com/taosdata/libtaos-rs.git |
max_upload_size | |
id | 388407 |
size | 339,563 |
Crates.io Version | Crates.io Downloads | CodeCov |
---|---|---|
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).
if you use the default features, it'll depend on:
In-design features:
rest
.r2d2
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
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(())
}
Welcome for all contributions.
Keep same with TDengine.