python aioinflux`serialization.usertype.schemeerror:schemeerror:可以有一个以上的时间戳型属性',如何避免它?

发布于 2025-01-27 02:28:45 字数 1137 浏览 6 评论 0原文

我有这个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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

双马尾 2025-02-03 02:28:45

字段的有效值类型仅是:float,integer,uinteger,string,boolean(参考

您能做的是将日期存储为整数(时间戳)或字符串(RFC3339格式)。
然后,您可以将其放回通量查询中,如果需要,请使用:

  1. totime() 方便地转换_value
  2. 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:

  1. toTime() to conveniently convert _value
  2. time() to convert single values (e.g., within map())
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文