HowTo? CURRENT_TIMESTAMP AT TIME ZONE 'UTC'

后端 未结 1 1960
孤独总比滥情好
孤独总比滥情好 2020-12-08 10:42

How would I amend my calls to

sqlalchemy.func.current_timestamp()

with something that generates

CURRENT_TIMESTAMP AT TIME          


        
相关标签:
1条回答
  • 2020-12-08 11:31

    A quick fix would be to do the following:

    func.current_timestamp().op('AT TIME ZONE')('UTC')
    

    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())
    
    0 讨论(0)
提交回复
热议问题