16 releases

0.5.2 Jun 6, 2022
0.5.1 Jan 5, 2022
0.5.0 Feb 6, 2021
0.4.5 Nov 12, 2020
0.2.2 Jun 30, 2017

#738 in Database interfaces

Download history 1783/week @ 2023-11-18 1966/week @ 2023-11-25 1718/week @ 2023-12-02 1688/week @ 2023-12-09 1964/week @ 2023-12-16 685/week @ 2023-12-23 1036/week @ 2023-12-30 1985/week @ 2024-01-06 2133/week @ 2024-01-13 2066/week @ 2024-01-20 2139/week @ 2024-01-27 2596/week @ 2024-02-03 2700/week @ 2024-02-10 2285/week @ 2024-02-17 1543/week @ 2024-02-24 1806/week @ 2024-03-02

8,691 downloads per month
Used in 14 crates (9 directly)

MIT license

36KB
816 lines

InfluxDBClient-rs

image Build Status

A easy-use client to influxdb

Overview

This is an InfluxDB driver for Rust.

Status

This project has been able to run properly, PR is welcome.

Usage

Use

[dependencies]
influx_db_client = "^0.5.0"

http

use influx_db_client::{
    Client, Point, Points, Value, Precision, point, points
};
use tokio;

fn main() {
    // default with "http://127.0.0.1:8086", db with "test"
    let client = Client::default().set_authentication("root", "root");

    let point = point!("test1")
        .add_field("foo", "bar")
        .add_field("integer", 11)
        .add_field("float", 22.3)
        .add_field("'boolean'", false);

    let point1 = Point::new("test1")
        .add_tag("tags", "\\\"fda")
        .add_tag("number", 12)
        .add_tag("float", 12.6)
        .add_field("fd", "'3'")
        .add_field("quto", "\\\"fda")
        .add_field("quto1", "\"fda");

    let points = points!(point1, point);

    tokio::runtime::Runtime::new().unwrap().block_on(async move {
        // if Precision is None, the default is second
        // Multiple write
        client.write_points(points, Some(Precision::Seconds), None).await.unwrap();

        // query, it's type is Option<Vec<Node>>
        let res = client.query("select * from test1", None).await.unwrap();
        println!("{:?}", res.unwrap()[0].series)
    });
}

udp

use influx_db_client::{UdpClient, Point, Value, point};

fn main() {
    let mut udp = UdpClient::new("127.0.0.1:8089");
    udp.add_host("127.0.0.1:8090");

    let point = point!("test").add_field("foo", Value::String(String::from("bar")));

    udp.write_point(point).unwrap();
}

Compatibility

This is the API Document, it may apply to version 1.0 or higher.

I have tested it in version 1.0.2/1.3.5/1.5.

Thanks

Because influent seems to have no longer updated, and only support to the 0.9 version. I read influent.rs and influxdb-python source, and then try to write a library for 1.0+ version for support for my own use.

Dependencies

~4–19MB
~291K SLoC