So I have a schema that I defined and use with aioinflux
library to write data from Python to InfluxDB
:
from datetime import datetime
from aioinflux import lineprotocol, TIMEDT, TAG, FLOAT, MEASUREMENT, INT
from dataclasses import dataclass
from typing import Optional
@lineprotocol(
schema=dict(
timestamp=TIMEDT,
measurement=MEASUREMENT,
object_id=INT,
dt=TAG,
weight=FLOAT,
width=FLOAT,
size=FLOAT,
risk=TAG,
confidence=FLOAT,
)
)
@dataclass
class CbdrDebugPoint:
timestamp: datetime
object_id: int
dt: str
weight: float
size: Optional[float]
width: Optional[float]
risk: Optional[str]
confidence: Optional[float]
measurement: str = "my_table_name"
but if any of my Optional
fields get value equal to None
the writing to influx fails with the following error:
TypeError("Invalid variable type: value should be str, int or float, got None")
but for sure it is possible to write null
values to influx, so any idea why does this error appear?