Sqlalchemy使用func.now()将来将一个字段设置为1小时
我想将未来的时间戳存储在我的数据库中,但理想情况下使用SQLalchemy的func.now()
函数和timedelta。这可能吗?类似:
new_obj = MyTable(event_time=(func.now() + OFFSET))
我可以使用dateTime.utcnow()
来做到这一点,但这不是100%理想。似乎应该有可能使用偏移来进行func.now()
,并且避免解释为什么我们的事件和创建的时间戳略微不匹配,即使这是次秒差异。
I want to store a future timestamp in my DB but ideally using SQLAlchemy's func.now()
function and a timedelta. Is this possible? Something like:
new_obj = MyTable(event_time=(func.now() + OFFSET))
I can do this using datetime.utcnow()
but it's not 100% ideal. It seems like it should be possible to do func.now()
with an offset, and it would avoid explaining why our event and created timestamps are slightly mismatched, even if it is a sub-second difference.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
以下操作:
或:
您可以在此处找到 timedelta上的文档: htttps:// https:// docs.python.org/3/library/datetime.html
you can do the following:
or:
Documentation on timedelta can be found here: https://docs.python.org/3/library/datetime.html