如何在 influxdb 中获取 table 的列名

How to get column names of a table in influxdb

我正在尝试使用一个我几乎不了解的数据库,我需要知道 table:

的列名

这是我尝试过的:

client = DataFrameClient(host, 8086, username, password, "marketdata")
client.switch_database('marketdata')
print(client.query("show measurements"))
# ResultSet({'('measurements', None)': [{'name': 'bookTicker'}]})

query = "SELECT COUNT(DISTINCT bookTicker) FROM information_schema.columns WHERE table_schema = 'marketdata'"

dataframes = client.query(query)
raise InfluxDBClientError(self.error)
influxdb.exceptions.InfluxDBClientError: retention policy not found: information_schema

我也试过:

query = "select * from bookTicker limit 10"
raise ChunkedEncodingError(e)
requests.exceptions.ChunkedEncodingError: ("Connection broken: InvalidChunkLength(got length b'', 0 bytes read)", InvalidChunkLength(got length b'', 0 bytes read))

您正在尝试将 SQL 知识用于非 SQL InfluxDB。

InfluxDB 没有列的概念,但是标签(在 SQL 中表示类似于索引列)和字段(类似于列)。

您可以通过以下查询探索它们:

SHOW TAG KEYS [ON <database_name>] [FROM_clause] [WHERE <tag_key> ['<tag_value>' | <regular_expression>]] [LIMIT_clause] [OFFSET_clause]

https://docs.influxdata.com/influxdb/v1.7/query_language/schema_exploration/#show-tag-keys

SHOW FIELD KEYS [ON <database_name>] [FROM <measurement_name>]

https://docs.influxdata.com/influxdb/v1.7/query_language/schema_exploration/#show-field-keys