如何?时区 'UTC' 的 CURRENT_TIMESTAMP [英] HowTo? CURRENT_TIMESTAMP AT TIME ZONE 'UTC'
本文介绍了如何?时区 'UTC' 的 CURRENT_TIMESTAMP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我将如何修改我的电话
sqlalchemy.func.current_timestamp()
产生的东西
CURRENT_TIMESTAMP AT TIME ZONE 'UTC'
推荐答案
快速解决方法是执行以下操作:
A quick fix would be to do the following:
func.current_timestamp().op('AT TIME ZONE')('UTC')
更合适的方法是使用编译器扩展并定义的自定义编译CURRENT_TIMESTAMP
.实际上,它的文档中已经有一个 example,它使用了不同的方法(TIMEZONE
函数).由于您只需要 Postgres 使用它(我从您之前在 SA 邮件列表中的电子邮件中假设您正在使用 Postgres),这是另一个(更好的)快速修复:
A more proper way is to use compiler extension and define custom compilation of CURRENT_TIMESTAMP
. Actually, there's already an example in its docs, which uses a different approach (TIMEZONE
function). Since you only need this for Postgres (I assume from your previous emails in SA mailing list that you're using Postgres), here's another (nicer) quick fix:
func.timezone('UTC', func.current_timestamp())
这篇关于如何?时区 'UTC' 的 CURRENT_TIMESTAMP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文