【问题标题】:How to get column names of a table in influxdb如何在 influxdb 中获取表的列名
【发布时间】:2021-07-06 16:43:15
【问题描述】:

我正在尝试使用我几乎不知道并且需要知道表的列名的数据库:

这是我尝试过的:

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

【问题讨论】:

    标签: influxdb influxdb-python


    【解决方案1】:

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

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

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

    显示标签键 [ON ] [FROM_clause] [WHERE ['' | ]] [LIMIT_clause] [OFFSET_clause]

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

    显示字段键 [ON ] [FROM ]

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-10-15
      • 2012-02-18
      • 2017-03-23
      • 1970-01-01
      • 2015-09-28
      • 2013-01-27
      • 2011-11-08
      相关资源
      最近更新 更多