TDengine/docs/examples/rust/nativeexample/examples/connect.rs

18 lines
444 B
Rust
Raw Normal View History

use taos::*;
#[tokio::main]
2024-08-12 09:29:17 +00:00
async fn main() -> anyhow::Result<()> {
let dsn = "taos://localhost:6030".to_string();
match TaosBuilder::from_dsn(&dsn)?.build().await {
Ok(_taos) => {
println!("Connected to {} successfully.", dsn);
Ok(())
}
Err(err) => {
2024-08-14 08:25:22 +00:00
eprintln!("Failed to connect to {}, ErrMessage: {}", dsn, err);
2024-08-12 09:29:17 +00:00
return Err(err.into());
}
}
}