首页 > 解决方案 > sqlalchemy中的时间戳操作

问题描述

我正在尝试比较两个时间戳,例如xy,其中 y 应该是当前时间戳减去一定的秒数s,例如y = sa.func.current_timestamp() - s。但似乎这y不是一个时间戳。如何将其转换为时间戳?

示例代码

def foo(x, y):
    # x is a timestamp, y is number of seconds
    y = sa.func.current_timestamp() - y
    return x > y

标签: datetimesqlalchemytimestamp

解决方案


推荐阅读