使用restbed 写入influxDB 数据库
发布日期:2021-05-15 02:56:30 浏览次数:17 分类:精选文章

本文共 3673 字,大约阅读时间需要 12 分钟。

������InfluxDB ���������

InfluxDB ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������

������������������

InfluxDB ��� MySQL ������

���������������������������InfluxDB ���������������������MySQL ������������������������������������������

InfluxDB ���������������
database ���������
measurement ������������������
points ���������������������

���������������������InfluxDB ������������������������������������������������

InfluxDB ���������������

���InfluxDB ������������������������������ ������Point���������������������������������������������

Point ������ ������������
time ������������������������������������
fields ������������������������������������
tags ������������������������������������������������������

���������������������InfluxDB ���������������������������������������������������������

������������

���InfluxDB ���������������������������������

HTTP ������ ������������������ 8086���

InfluxDB HTTP API ������

��������������������������������������� SDK ��� HTTP API ���InfluxDB ������������������������������������ HTTP API ������������������

������ API ��������� curl ��������� POSTMAN ���������

���������������

������ HTTP ������ ������������������������������������������������

������ curl ���������

curl -X POST http://localhost:8086/query --data-urlencode "q=CREATE DATABASE mydb"

������ POSTMAN���

��� POSTMAP ��������� POST ��������������� Content-Type ��� application/x-www-form-urlencoded��������������������� CREATE DATABASE mydb ��������� Body ������

������������

InfluxDB ������������ HTTP ������ ���������������������������������������������������

������ curl ���������

curl -i -X POST http://localhost:8086/write?db=mydb -d 'vibration,host=localhost value=0.64'

������ POSTMAN���

��� POSTHOOK ��������� POST ��������������� Content-Type ��� application/x-www-form-urlencoded������ Body ��������� vibration,host=localhost value=32.145���

���������������������InfluxDB ������������������������������������������������������

���������������

���������������������������������������������������������������

������ curl ���������

curl -X POST http://localhost:8086/query --data-urlencode "q=DROP DATABASE mydb"

C++ InfluxDB ���������������

��������������������������� C++ ������������ interacting with InfluxDB ��������������������� restbed ������������������������

��������������� restbed ��� C++ ������������������������

#include 
#include
#include
using namespace std;
class InfluxDBClient {
private:
const string DB_HOST;
const string DB_PORT;
// ������������
const int SLEEP_TIME = 1;
public:
InfluxDBClient(const string &db_host, const string &db_port)
: DB_HOST(db_host), DB_PORT(db_port) {
// ���������������������������
measles_create_database();
}
void write_data(const string &measurement, const float &value) {
//nila Additionally���������
}
// ������������������...
};
// ������������
int main() {
string db_address = "localhost:8086";
string database_name = "mydb";
string measurement_name = "vibration,host=localhost";
// ������������������
InfluxDBClient client(db_address, "8086");
float value = 0.6;
while (true) {
client.write_data(measurement_name, value);
value += 0.1;
sleep(SLEEP_TIME);
}
return 0;
}

���������������������InfluxDB ���������������������������������������������������������������������������������������������������������������������

<h2 ���������������>���������InfluxDB ������������������������������������������������������������������ IoT ���������������������������������������������������������������������������������������������������������������

上一篇:C++ influxdb 客户端
下一篇:C++ strptime 和strptime函数的使用方式

发表评论

最新留言

不错!
[***.144.177.141]2025年04月21日 09时10分39秒