如何在influxdb中获取表的列名

问题描述

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

这是我尝试过的:

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 @R_493_4045@ion_schema.columns WHERE table_schema = 'marketdata'"

dataframes = client.query(query)
raise InfluxDBClientError(self.error)
influxdb.exceptions.InfluxDBClientError: retention policy not found: @R_493_4045@ion_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))

解决方法

您正在尝试将 num2find = int(input("Enter a number to find: ")) found = False # rename flag with open("testfile.txt") as test_file: # use with to avoid missing closing the file for line in test_file: # use a for loop to iterate over each line in the file num = int(line) if num == num2find: found = True break if found: # print results at the end once file was processed print("Number found.") else: print("Number not found.") 知识用于非 SQL InfluxDB。

SQL 没有列的概念,但有标签(在 SQL 中的意思是索引列之类的东西)和字段(类似于列的东西)。

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

SHOW TAG KEYS [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