influx_query ()

阅读(32) 标签: 查询, influxdb,

描述:

查询influxdb数据库

语法:

influx_query(hd,sql)

备注:

外部库函数,查询influxdb外部库。

参数:

hd

连接对象

sql

sql查询语句或查看数据库相关信息的语句

返回值:

查询结果集

示例:

 

A

B

1

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

//连接数据库

2

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

//查询表instance

3

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

//同上

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")

//查询表h2o_feet中的water_level平均值

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")

//创建连接查询语句

6

=influx_query(A1, "SHOW DATABASES")

//显示数据库

7

=influx_query(A1, "SHOW RETENTION POLICIES")

//显示保留策略

8

=influx_query(A1, "SHOW SHARDS")

//显示shard

9

=influx_close(A1)

//关闭数据库