Giter VIP home page Giter VIP logo

influxdbclient-rs's Introduction

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.4.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", Value::String("bar".to_string()))
        .add_field("integer", Value::Integer(11))
        .add_field("float", Value::Float(22.3))
        .add_field("'boolean'", Value::Boolean(false));

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

    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.

influxdbclient-rs's People

Contributors

caemor avatar chrisca avatar driftluo avatar francois2metz avatar juchiast avatar laibulle avatar miracle2k avatar mmmaisel avatar mvines avatar netzdoktor avatar qwandor avatar rjancewicz avatar rnestler avatar thewawar avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.