Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PostgreSQL utc_now() needs to have specific UTC timezone #9

Open
yesthesoup opened this issue Mar 16, 2020 · 0 comments
Open

PostgreSQL utc_now() needs to have specific UTC timezone #9

yesthesoup opened this issue Mar 16, 2020 · 0 comments

Comments

@yesthesoup
Copy link

default_sql_now returns CURRENT_TIMESTAMP for psql, but without specifying UTC this returns the server's local time.

SQLAlchemy docs recommend the following implementation for a psql utc_now():

@compiles(utcnow, 'postgresql')
def pg_utcnow(element, compiler, **kw):
    return "TIMEZONE('utc', CURRENT_TIMESTAMP)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant