Library for talking to InfluxDB
This library is a work in progress. Although we've been using it in production at OpenVelo, we're prioritized features that fit our use cases. This means a feature you might need is not implemented yet or could be handled better.
Pull requests are always welcome.
Currently Supported Features
- Reading and Writing to InfluxDB
- Optional Serde Support for Deserialization
Planned Features
- Running multiple queries in one request (e.g.
SELECT * FROM weather_berlin; SELECT * FROM weather_london
) - Read Query Builder instead of supplying raw queries
- Authentication against InfluxDB
- Methods for setting time and time precision in a query
Quickstart
Add the following to your Cargo.toml
= "0.0.1"
For an example with using Serde deserialization, please refer to serde_integration
use ;
use InfluxDbClient;
use Deserialize;
use Runtime;
// Create a InfluxDbClient with URL `http://localhost:8086`
// and database name `test`
let client = new;
// Let's write something to InfluxDB. First we're creating a
// InfluxDbWriteQuery to write some data.
// This creates a query which writes a new measurement into a series called `weather`
let write_query = write_query
.add_field;
// Since this library is async by default, we're going to need a Runtime,
// which can asynchonously run our query.
// The [tokio](https://crates.io/crates/tokio) crate lets us easily create a new Runtime.
let mut rt = new.expect;
// To actually submit the data to InfluxDB, the `block_on` method can be used to
// halt execution of our program until it has been completed.
let write_result = rt.block_on;
assert!;
// Reading data is as simple as writing. First we need to create a query
let read_query = raw_read_query;
// Again, we're blocking until the request is done
let read_result = rt.block_on;
assert!;
// We can be sure the result was successful, so we can unwrap the result to get
// the response String from InfluxDB
println!;
For further examples, check out the Integration Tests in tests/integration_tests.rs
in the repository.