influx_query()

Read(3467) Label: query, influxdb,

Description:

Query InfluxDB database.

Syntax:

influx_query(hd,sql)

Note:

The external library function (See External Library Guide) queries InfluxDB database. It is valid only with InfluxDB 1.x.

Parameter:

hd

Connection object

sql

The SQL query statement or database search statement

Return value:

Query result set

Example:

 

A

B

1

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

Connect to database

2

=influx_query(A1, "SELECT * FROM instance")

Query instance table

3

=influx_query(A1, "SELECT /l/ FROM instance LIMIT 1")

Same as A2

4

=influx_query(A1, "SELECT MEAN(water_level) FROM h2o_feet WHERE time >= '2019-08-18T00:00:00Z' AND time <= '2019-08-18T00:42:00Z' GROUP BY *,time(12m)  SLIMIT 5")

Query the water_level average in h2o_feet table

5

=influx_query(A1, "CREATE CONTINUOUS QUERY \"cq_basic_br\" ON \"transportation\"" +

  "BEGIN "+

  "  SELECT mean(*) INTO \"downsampled_transportation\".\"autogen\".:MEASUREMENT FROM /.*/ GROUP BY time(30m),* "+

  "END")

Create the connection query statement

6

=influx_query(A1, "SHOW DATABASES")

Show the database

7

=influx_query(A1, "SHOW RETENTION POLICIES")

Show the retention policy

8

=influx_query(A1, "SHOW SHARDS")

Show shards

9

=influx_close(A1)

Close the database