influx_insert ()

阅读(1713) 标签: 插入, influxdb,

描述:

influxdb数据库插入数据。

语法:

influx_insert(hd,string/string[])

备注:

外部库函数,外部库的使用请参考《外部库使用指南》。

influxdb插入单条或多条数据,仅供InfluxDB版本为1.x时使用。

字符串参数格式为:<measurement>[,<tag-key>=<tag-value>...] <field-key>=<field-value>[,<field2-key>=<field2-value>...] [unix-nano-timestamp];顺序为:表名(不存在表则新建)、tag-key=tag-valuefield-key=field-value、时间戳。注意时间戳前的空格。

参数:

hd

连接对象。

string

行协议字符或行协议字符数组。数据的格式需要满足InfluxDB行协议,时间戳为UTC时间或yyyy-MM-ddTHH:mm:ssyyyy-MM-ddTHH:mm:ssXXZ格式。

返回值:

插入成功的记录数

示例:

 

A

1

=influx_open("http://127.0.0.1:8086", "mydb", "autogen", "admin", "admin")

2

=influx_insert(A1, "h2o_feet,location=santa_monica,direct=5 water_level=2.064 1566086400000000000")

3

=influx_insert(A1, "h2o_feet,location=santa_jack,direct=5 water_level=2.164 2019-08-18T00:30:00Z")

4

=influx_insert(A1, ["h2o_feet,location=santa_jack,direct=7 water_level=2.264 1566087500000000","h2o_feet,location=santa_php,direct=8 water_level=2.316 1566086770000000000"])

5

=influx_insert(A1, ["h2o_feet,location=santa_last,direct=9 water_level=2.464 1566087200000","h2o_feet,location=santa_php,direct=8 water_level=2.516 1566086780000000000"])

6

=insert_close(A1)