data_tools.query.FluxQuery#
- class data_tools.query.FluxQuery#
Bases:
objectRepresent a Flux query: a collection of
FluxStatementchained together to form a complete query to our InfluxDB database.Supports method chaining for fluent construction of queries.
- __init__()#
Instantiate an empty Flux query. :return: this FluxQuery with the new statement inserted
Methods
__init__()Instantiate an empty Flux query.
car(car)Filter for data from a specific car.
Compile this object into a Flux query, as a string.
filter([measurement, field])Apply a filter to the query.
from_bucket(bucket)Specify the bucket that will be queried from.
inject_raw(statement)Inject a FluxStatement into this query.
range(start[, stop])Specify the time range of the time-series data to query.
- car(car: str)#
Filter for data from a specific car.
- Parameters:
car – car name, such as “Brightside”.
- Returns:
this FluxQuery with the new statement inserted
- compile_query() str#
Compile this object into a Flux query, as a string.
- Returns:
the canonical string representation of this Flux query, with statements ordered according to priority.
- filter(measurement: str = None, field: str = None)#
Apply a filter to the query. Any or both of
measurementandfieldmay be specified and both filters will be applied. No effect if neither is.- Parameters:
measurement (str) – measurement to filter for, such as “BMS”
field (str) – field to filter for, such as “PackCurrent”.
- Returns:
this FluxQuery with the new statement inserted
- from_bucket(bucket: str)#
Specify the bucket that will be queried from.
- Parameters:
bucket (str) – bucket name
- Returns:
this FluxQuery with the new statement inserted
- inject_raw(statement: FluxStatement)#
Inject a FluxStatement into this query. This may be necessary if the Flux statement is not available with the existing built-in Flux statements.
- Parameters:
statement
- Returns:
this FluxQuery with the new statement inserted
- range(start: str, stop: str = None)#
Specify the time range of the time-series data to query.
- Parameters:
start – start time of the time range as an ISO 8601 compliant string.
stop – stop time of the time range as an ISO 8601 compliant string, optional.
- Returns:
this FluxQuery with the new statement inserted