asphalt.influxdb.client
¶
-
class
asphalt.influxdb.client.
DataPoint
(measurement: str, tags: typing.Dict[str, typing.Any], fields: typing.Dict[str, typing.Union[int, float, decimal.Decimal, str]], timestamp: typing.Union[datetime.datetime, int] = None) → None¶ Bases:
object
Represents a data point to be written to the database.
Variables: - measurement (str) – name of the measurement
- tags – a dictionary of tag names to values
- fields – a dictionary of field names to values
- timestamp – time stamp for the measurement
-
class
asphalt.influxdb.client.
InfluxDBClient
(base_urls: typing.Sequence[str] = 'http://localhost:8086', db: str = None, username: str = None, password: str = None, consistency: str = None, retention_policy: str = None, precision: str = None, chunked: int = None, epoch: str = None, session: typing.Union[aiohttp.client.ClientSession, str] = None, timeout: int = 60) → None¶ Bases:
object
An asyncio based InfluxDB client.
To set advanced connection options like HTTP authentication, client certificates etc., see the documentation of the
ClientSession
and provide your ownsession
argument to the constructor of this class.Parameters: - base_urls (
Sequence
[str
]) – an HTTP URL pointing to the InfluxDB server (or several URLs, in case of an InfluxEnterprise cluster) - db (
Optional
[str
]) – default database to use - username (
Optional
[str
]) – default user name to use for per-request authentication - password (
Optional
[str
]) – default password to use for per-request authentication - consistency (
Optional
[str
]) – default write consistency (for InfluxEnterprise) – one ofany
,one
,quorum
,all
orNone
- precision (
Optional
[str
]) – default timestamp precision for writes – one ofn
,u
,ms
,s
,m
,h
orNone
- epoch (
Optional
[str
]) – default timestamp precision for queries – one ofn
,u
,ms
,s
,m
,h
orNone
- retention_policy (
Optional
[str
]) – default retention policy name to use for writes - session (
Union
[ClientSession
,str
,None
]) – an aiohttp session or a resource name of one (if omitted, one is created automatically and closed when the client is closed) - timeout (
int
) – timeout (in seconds) for all HTTP requests
-
coroutine
ping
(self)¶ Check connectivity to the server.
Return type: str
Returns: value of the X-Influxdb-Version
response headerRaises: InfluxDBError – if the server returns an error or an unexpected HTTP status code
-
query
(select, from_, **kwargs)¶ Create a query builder.
To execute the query, call its
execute()
method.Parameters: - select (
Iterable
[str
]) – expressions to select - from (
Iterable
[str
]) – measurements to select from - kwargs – keyword arguments to pass to
SelectQuery
Return type: Returns: a query builder object
- select (
-
coroutine
raw_query
(self, query, *, http_verb=None, **query_params)¶ Send a raw query to the server.
Parameters: Return type: Returns: depending on the query and the results:
None
(if there are no series or errors in the results)- a single series
- a list of series (if selecting from more than one measurement)
- a list of lists of series (if the query string contained multiple queries)
Raises: InfluxDBError – if the server returns an error or an unexpected HTTP status code
-
coroutine
write
(self, measurement, tags, fields, timestamp=None, **write_params)¶ Write a single data point to the database.
This is a shortcut for instantiating a
DataPoint
and passing it in a tuple towrite_many()
.Note
If the timestamp is given as an integer, it must match with the
precision
option the client was initialized with.Parameters: - measurement (
str
) – name of the measurement - tags (
Dict
[str
,Any
]) – a dictionary of tag names to values - fields (
Dict
[str
,Union
[float
,Decimal
,bool
,str
]]) – a dictionary of field names to values - timestamp (
Union
[datetime
,int
,None
]) – time stamp for the measurement - write_params – overrides for default write parameters
Raises: InfluxDBError – if the server returns an error or an unexpected HTTP status code
Return type: - measurement (
-
coroutine
write_many
(self, datapoints, **write_params)¶ Write the given data points to the database.
Parameters: Raises: InfluxDBError – if the server returns an error or an unexpected HTTP status code
Return type:
- base_urls (