Python aioinflux `serialization.usertype.SchemaError: Can't have more than one timestamp-type attribute`, how to avoid it?
Python aioinflux `serialization.usertype.SchemaError: Can't have more than one timestamp-type attribute`, how to avoid it?
我有这个 dataclass
和这样的 lineprotocol
架构:
from datetime import date, datetime
from aioinflux import lineprotocol, TIMEDT, TAG, FLOAT, MEASUREMENT, STR, INT
from dataclasses import dataclass
from shared import DEBUG_TABLE_NAME
@lineprotocol(
schema=dict(
timestamp=TIMEDT,
measurement=MEASUREMENT,
target_id=INT,
type=TAG,
weight=FLOAT,
confidence=FLOAT,
statement=TAG,
now_time=TIMEDT,
height=INT,
dt_time=TIMEDT,
success=TAG,
)
)
@dataclass
class DataPoint:
timestamp: datetime
target_id: int
type: str
weight: float
confidence: float
statement: str
now_time: datetime
height: int
dt_time: datetime
success: str
measurement: str = DEBUG_TABLE_NAME
但是在尝试 运行 代码时出现此错误:
aioinflux.serialization.usertype.SchemaError: Can't have more than one timestamp-type attribute [~TIMEINT, ~TIMEDT, ~TIMESTR]
我还需要一些其他属性,例如 now_time
和 dt_time
,时间格式要短一些。但这似乎引发了 aioinflux
的错误。如何避免这种情况?
我有这个 dataclass
和这样的 lineprotocol
架构:
from datetime import date, datetime
from aioinflux import lineprotocol, TIMEDT, TAG, FLOAT, MEASUREMENT, STR, INT
from dataclasses import dataclass
from shared import DEBUG_TABLE_NAME
@lineprotocol(
schema=dict(
timestamp=TIMEDT,
measurement=MEASUREMENT,
target_id=INT,
type=TAG,
weight=FLOAT,
confidence=FLOAT,
statement=TAG,
now_time=TIMEDT,
height=INT,
dt_time=TIMEDT,
success=TAG,
)
)
@dataclass
class DataPoint:
timestamp: datetime
target_id: int
type: str
weight: float
confidence: float
statement: str
now_time: datetime
height: int
dt_time: datetime
success: str
measurement: str = DEBUG_TABLE_NAME
但是在尝试 运行 代码时出现此错误:
aioinflux.serialization.usertype.SchemaError: Can't have more than one timestamp-type attribute [~TIMEINT, ~TIMEDT, ~TIMESTR]
我还需要一些其他属性,例如 now_time
和 dt_time
,时间格式要短一些。但这似乎引发了 aioinflux
的错误。如何避免这种情况?