SqlAlchemy 支持这样的Interval 数据类型:
class Sample(Base):
__tablename__ = "samples"
id = Column(Integer(), primary_key=True)
time_interval = Column(Interval(), nullable=True)
是否可以使用 Marshmallow 模式序列化间隔列类型?我希望得到类似以下的东西:
class SampleSchema(Schema):
id = fields.Int()
time_interval = fields.Interval(allow_none=True) # not supported
...但是Marshmallow 不支持区间数据类型。Marshmallow API 文档提到了其他原始数据类型和字符串,但到目前为止我还不能让它工作。
TypeError: Object of type 'timedelta' is not JSON serializable
感谢您提供任何提示或建议。