How to get list of names of all measurements from InfluxDB cloud in python?

Hi, I have initiated the connection to influxdb cloud with the following python codes :-

import influxdb_client

bucket = "<my-bucket>"
org = "<my-org>"
token = "<my-token>"
# Store the URL of your InfluxDB instance

client = influxdb_client.InfluxDBClient(url=url, token=token,  org=org)

For the codes to list out all measurements, I found the following codes but Pycharm compiler complained that ‘influxdata/influxdb/schema’ is not found. Please help me. Thanks.

import "influxdata/influxdb/schema"

schema.measurements(bucket: "example-bucket")

Yes, because this is no valid python code… no idea where you got this code snippet from…

@bednar any thoughts on this? Thank you

Hi @Anaisdg, @lyhooi

the following code snippet will be work:

from influxdb_client import InfluxDBClient

Configure credentials
influx_cloud_url = ''
influx_cloud_token = 'my-token'
bucket = 'my-bucket'
org = 'my-org'

client = InfluxDBClient(url=influx_cloud_url, token=influx_cloud_token)

Query to all measurements
query = f"""
import \"influxdata/influxdb/schema\"

schema.measurements(bucket: \"{bucket}\")

print(f'Query: \n {query}')

query_api = client.query_api()
tables = query_api.query(query=query, org=org)

# Flatten output tables into list of measurements
measurements = [row.values["_value"] for table in tables for row in table]

print('Measurements: ')




Do you know if it’s a way to get the tag values in a range of time (from_time to_time)?