influx_insert()

Read(3493) Label: insert, influxdb,

Description:

Insert one or more records to InfluxDB database.

Syntax:

influx_insert(hd,string/string[])

Note:

The external library function (See External Library Guide) inserts one or more records to InfluxDB database. It is valid only with InfluxDB 1.x.

 

The format of string parameters is <measurement>[,<tag-key>=<tag-value>…] <field-key>=<field-value>[,<field2-key>=<field2-value>…] [unix-nano-timestamp]. Their order is table name (create one if the table does not exist), tag-key=tag-value, field-key=field-value, and time stamp. Note that there is a space before the time stamp.

Parameter:

hd

Connection object

string

Line protocol characters or line protocol arrays of characters. Data format should meet the requirements of InfluxDB line protocol; time stamp is represented in UTC or is in the format of yyyy-MM-ddTHH:mm:ss/yyyy-MM-ddTHH:mm:ssXXZ

Return value:

Number of records inserted

Example:

 

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)