【发布时间】:2018-02-07 02:38:15
【问题描述】:
SqlAlchemy 像这样支持Interval data types:
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 不支持 interval 数据类型。 Marshmallow API documentation 提到了其他原始数据类型和字符串,但到目前为止我还不能让它工作。
TypeError: Object of type 'timedelta' is not JSON serializable
感谢您的任何提示或建议。
【问题讨论】:
标签: python postgresql sqlalchemy marshmallow