python aioinflux`serialization.usertype.schemeerror:schemeerror:可以有一个以上的时间戳型属性',如何避免它?
我有这个dataclass
,带有lineProtocol
schema,例如:
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.schemeerror:不能有一个以上的时间戳型属性[〜TimeInt,〜TimeInt,〜TimeDt,〜TimEstr]
我仍然需要其他一些属性,例如now_time_time _time _time _ /code>和
dt_time
在某些时间格式中。但这似乎引发了aioinflux
的错误。如何避免这种情况?
I have this dataclass
with a lineprotocol
schema like this:
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
but when trying to run the code i get this error:aioinflux.serialization.usertype.SchemaError: Can't have more than one timestamp-type attribute [~TIMEINT, ~TIMEDT, ~TIMESTR]
I still need to have some other attributes like now_time
and dt_time
in, some short, of time format. But this seems to be raising an error for aioinflux
. How can this be avoided?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
字段的有效值类型仅是:float,integer,uinteger,string,boolean(参考)
您能做的是将日期存储为整数(时间戳)或字符串(RFC3339格式)。
然后,您可以将其放回通量查询中,如果需要,请使用:
totime()
方便地转换_value
time()
转换单个值(例如,在map()
中)Valid value types for fields are only: Float, Integer, UInteger, String, Boolean (Reference)
What you can do, is to store the date either as an integer (timestamp) or a string (RFC3339 format).
You can then cast it back in Flux queries, if need be, using:
toTime()
to conveniently convert_value
time()
to convert single values (e.g., withinmap()
)