asphalt.influxdb.query

class asphalt.influxdb.query.KeyedTuple(columns: typing.Dict[str, int], row: typing.List) → None

Bases: object

Represents a single result row from a SELECT query.

Columns can be accessed either as attributes or in a dict-like manner. This class also implements __len__ plus all equality and comparison operators.

class asphalt.influxdb.query.SelectQuery(client, select: str, from_: str, into: str = '', where: str = '', group_by: str = '', descending: bool = False, limit: int = None, offset: int = None, slimit: int = None, soffset: int = None, query_params: typing.Dict[str, typing.Any] = None) → None

Bases: object

Programmatic builder for SELECT queries.

The query is considered immutable. None of the methods mutate existing queries, but rather return new copies of the original with the new parameters.

descending(value)

Set the sort order of the query.

Parameters:value (bool) – True to sort in descending order, False for ascending
Return type:SelectQuery
Returns:a new query
coroutine execute(self)

Execute the query on the server and return the result.

Return type:Union[Series, List[Series]]
Returns:a series or a list of series, depending on the query
group_by(*tags)

Augment or reset the GROUP BY clause in the query.

If a * is the existing GROUP BY clause or among the given tags, it will be set as the sole GROUP BY clause and all other tags will be ignored as they would be redundant.

With no arguments, the GROUP BY clause is reset. Otherwise, the expressions will be added to the existing GROUP BY clause.

Parameters:tags (str) – tags on which to group
Return type:SelectQuery
Returns:a new query
into(into)

Set the INTO expression in the query.

Parameters:into (str) – name of the measurement to write the query results into.
Return type:SelectQuery
Returns:a new query
limit(limit=None)

Set the LIMIT clause in the query.

Parameters:limit (Optional[int]) – the new LIMIT value
Return type:SelectQuery
Returns:a new query
offset(offset=None)

Set the OFFSET clause in the query.

Parameters:offset (Optional[int]) – the new OFFSET value
Return type:SelectQuery
Returns:a new query
params(**query_params)

Set or replace the HTTP query parameters for this query.

Return type:SelectQuery
Returns:a new query
select(*expressions)

Augment or reset the SELECT clause in the query.

With no arguments, the SELECT clause is reset. Otherwise, the expressions will be added to the existing SELECT clause.

Parameters:expressions (str) – raw InfluxQL expressions
Return type:SelectQuery
Returns:a new query
slimit(slimit=None)

Set the SLIMIT clause in the query.

Parameters:slimit (Optional[int]) – the new SLIMIT value
Return type:SelectQuery
Returns:a new query
soffset(soffset=None)

Set the SOFFSET clause in the query.

Parameters:soffset (Optional[int]) – the new SOFFSET value
Return type:SelectQuery
Returns:a new query
where(*expressions, **equals)

Augment or reset the WHERE clause in the query.

With no arguments, the WHERE clause is reset. Otherwise, the expressions will be joined to the existing WHERE clause using the AND operator.

Parameters:
  • expressions (str) – raw InfluxQL expressions
  • equals (Union[str, float, int, Decimal]) – key-value pairs which are transformed into expressions, quoting/transforming as necessary
Return type:

SelectQuery

Returns:

a new query

class asphalt.influxdb.query.Series(name: str, columns: typing.List[str], values: typing.List[list]) → None

Bases: object

Represents a series in the result set of a SELECT query.

Iterating over instances of this class will yield KeyedTuple instances.

Variables:
  • name (str) – name of the series
  • columns (tuple) – column names
  • values – result rows as a list of lists where the inner list elements correspond to column names in the columns attribute