influxdb_v1: removes write method, updates docs

This commit is contained in:
Mose Mueller 2024-12-17 07:19:41 +01:00
parent b19aeda16a
commit 9b2c26dc42
2 changed files with 15 additions and 45 deletions

View File

@ -107,9 +107,6 @@ with InfluxDBv1Session() as influx_client:
}
]
influx_client.write_points(data=data, database="other_database")
# just write one point into the client's current database
influx_client.write(data=data[0])
```
### InfluxDBSession

View File

@ -9,7 +9,7 @@ except ImportError:
from typing_extensions import Self
import influxdb
import influxdb # type: ignore
from confz import FileSource
from pydase_service_base.database.config import InfluxDBv1Config, ServiceConfig
@ -94,35 +94,6 @@ class InfluxDBv1Session:
) -> None:
self._client.close()
def write(
self,
data: dict[str, Any],
) -> Any:
"""Write data to InfluxDB.
Args:
data:
The data to be written.
Example:
```python
>>> data = {
"measurement": "cpu_load_short",
"tags": {
"host": "server01",
"region": "us-west"
},
"time": "2009-11-10T23:00:00Z",
"fields": {
"value": 0.64
}
}
>>> with InfluxDBv1Session() as client:
client.write(data=data)
```
"""
self._client.write(data=data)
def write_points( # noqa: PLR0913
self,
points: list[dict[str, Any]],
@ -158,19 +129,21 @@ class InfluxDBv1Session:
Example:
```python
>>> data = {
"measurement": "cpu_load_short",
"tags": {
"host": "server01",
"region": "us-west"
},
"time": "2009-11-10T23:00:00Z",
"fields": {
"value": 0.64
}
}
>>> points = [
... {
... "measurement": "cpu_load_short",
... "tags": {
... "host": "server01",
... "region": "us-west",
... },
... "time": "2009-11-10T23:00:00Z",
... "fields": {
... "value": 0.64,
... },
... }
... ]
>>> with InfluxDBv1Session() as client:
client.write(data=data)
... client.write_points(points=points)
```
"""