gpt4 book ai didi

influxdb - 如何在 influxdb 中获取表的列名

转载 作者:行者123 更新时间:2023-12-05 04:47:58 29 4
gpt4 key购买 nike

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

这是我尝试过的:

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

关于influxdb - 如何在 influxdb 中获取表的列名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68274418/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com