U
vi @ s d Z ddlZddlmZmZ ddlmZ ddlmZm Z m
Z
ddlmZm
Z
ddlmZmZ ddlmZ dd lmZ dd
lmZ edZerddlmZ G d
d deZdS )zKCollect and async write time series data to InfluxDB Cloud or InfluxDB OSS. N)
ensure_futuregather)defaultdict)UnionIterable
NamedTuple)PointWritePrecision)
_BaseWriteApi_HAS_DATACLASS)get_org_query_param)DEFAULT_WRITE_PRECISION)
PointSettingsz&influxdb_client.client.write_api_async) dataclassc s e Zd ZdZe fedd fdd
Zddefeeeee d e
e d ee d ee d e
e d
de d f eedd
dZ ZS )
WriteApiAsynca
Implementation for '/api/v2/write' endpoint.
Example:
.. code-block:: python
from influxdb_client_async import InfluxDBClientAsync
# Initialize async/await instance of Write API
async with InfluxDBClientAsync(url="http://localhost:8086", token="my-token", org="my-org") as client:
write_api = client.write_api()
N)point_settingsreturnc s t j||d dS )z
Initialize defaults.
:param influxdb_client: with default settings (organization)
:param point_settings: settings to store default tags.
)influxdb_clientr N)super__init__)selfr r __class__ W/opt/alt/python38/lib/python3.8/site-packages/influxdb_client/client/write_api_async.pyr " s zWriteApiAsync.__init__strr dictbytesr r )bucketorgrecordwrite_precisionr c
s t || jd}| | tt}| j|||fddi| g }| D ]2\}} |t| j j
||d| |dddd qFt|ddiI d H }
|
D ]}t
|tr|qdd
d |
D kS )a
Write time-series data into InfluxDB.
:param str bucket: specifies the destination bucket for writes (required)
:param str, Organization org: specifies the destination organization for writes;
take the ID, Name or Organization.
If not specified the default value from ``InfluxDBClientAsync.org`` is used.
:param WritePrecision write_precision: specifies the precision for the unix timestamps within
the body line-protocol. The precision specified on a Point has precedes
and is use for write.
:param record: Point, Line Protocol, Dictionary, NamedTuple, Data Classes, Pandas DataFrame
:key data_frame_measurement_name: name of measurement for writing Pandas DataFrame - ``DataFrame``
:key data_frame_tag_columns: list of DataFrame columns which are tags,
rest columns will be fields - ``DataFrame``
:key data_frame_timestamp_column: name of DataFrame column which contains a timestamp. The column can be defined as a :class:`~str` value
formatted as `2018-10-26`, `2018-10-26 12:00`, `2018-10-26 12:00:00-05:00`
or other formats and types supported by `pandas.to_datetime