mod api;
mod error;
mod types;
pub use api::QuestDB;
pub use error::Error;
pub use types::Schema;
use serde::Deserialize;
#[derive(Deserialize, Debug)]
struct TestData {
id: i32,
ts: String,
temp: f64,
sensor_id: i32,
}
#[cfg(test)]
mod tests {
use crate::{
api::QuestDB,
TestData,
new_schema,
Schema,
};
use std::fs::File;
#[tokio::test]
async fn test_exec() {
let connection = QuestDB::new("http://192.168.1.37:9000");
let _res = match connection.exec::<TestData>("select * from nu_table", Some(5), None, None).await {
Ok(res) => res,
Err(e) => {
println!("{}", e);
return;
}
};
}
#[tokio::test]
async fn test_imp() {
let connection = QuestDB::new("http://192.168.1.37:9000");
let schema = new_schema!(("movieId", Schema::String), ("imdbId", Schema::Int));
let _res = match connection.imp(
"./test.csv",
Some(schema),
"nu_table123",
None,
None,
None,
).await {
Ok(res) => res,
Err(e) => {
println!("{}", e);
return;
}
};
}
#[tokio::test]
async fn test_exp() {
let connection = QuestDB::new("http://192.168.1.37:9000");
let mut output_file = File::create("output.csv").unwrap();
let _res = match connection.exp("select * from nu_table", Some(5), &mut output_file).await {
Ok(res) => res,
Err(e) => {
println!("{}", e);
return;
}
};
}
}