This library is a work in progress. This means a feature you might need is not implemented yet or could be handled better.
Pull requests are always welcome. See Contributing and Code of Conduct. For a list of past changes, see CHANGELOG.md.
SELECT * FROM weather_berlin; SELECT * FROM weather_london
)WriteQuery
or Vec<WriteQuery>
argument)async
/await
support#[derive(InfluxDbWriteable)]
Derive Macro for Writing / Reading into StructsGROUP BY
supportAdd the following to your Cargo.toml
toml
influxdb = { version = "0.6", features = ["derive"] }
For an example with using Serde deserialization, please refer to serde_integration
```rust use influxdb::{Client, Query, Timestamp, ReadQuery}; use influxdb::InfluxDbWriteable; use chrono::{DateTime, Utc};
// or #[async_std::main] if you prefer
async fn main() {
// Connect to db test
on http://localhost:8086
let client = Client::new("http://localhost:8086", "test");
#[derive(InfluxDbWriteable)]
struct WeatherReading {
time: DateTime<Utc>,
humidity: i32,
#[influxdb(tag)] wind_direction: String,
}
// Let's write some data into a measurement called `weather`
let weather_readings = vec!(
WeatherReading {
time: Timestamp::Hours(1).into(),
humidity: 30,
wind_direction: String::from("north"),
}.into_query("weather"),
WeatherReading {
time: Timestamp::Hours(2).into(),
humidity: 40,
wind_direction: String::from("west"),
}.into_query("weather"),
);
let write_result = client
.query(weather_readings)
.await;
assert!(write_result.is_ok(), "Write result was not okay");
// Let's see if the data we wrote is there
let read_query = ReadQuery::new("SELECT * FROM weather");
let read_result = client.query(read_query).await;
assert!(read_result.is_ok(), "Read result was not ok");
println!("{}", read_result.unwrap());
} ```
For further examples, check out the Integration Tests in tests/integration_tests.rs
in the repository.
To communicate with InfluxDB, you can choose the HTTP backend to be used configuring the appropriate feature. We recommend sticking with the default reqwest-based client, unless you really need async-std compatibility.
hyper (through reqwest, used by default), with rustls
toml
influxdb = { version = "0.6", features = ["derive"] }
hyper (through reqwest), with native TLS (OpenSSL)
toml
influxdb = { version = "0.6", default-features = false, features = ["derive", "use-serde", "reqwest-client"] }
hyper (through surf), use this if you need tokio 0.2 compatibility
toml
influxdb = { version = "0.6", default-features = false, features = ["derive", "use-serde", "curl-client"] }
toml
influxdb = { version = "0.6", default-features = false, features = ["derive", "use-serde", "curl-client"] }
toml
influxdb = { version = "0.6", default-features = false, features = ["derive", "use-serde", "h1-client"] }
toml
influxdb = { version = "0.6", default-features = false, features = ["derive", "use-serde", "h1-client-rustls"] }
window.fetch
, via web-sys
and wasm-bindgen
toml
influxdb = { version = "0.6", default-features = false, features = ["derive", "use-serde", "wasm-client"] }
@ 2020 Gero Gerke and contributors.