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)"
default_sql_nowreturnsCURRENT_TIMESTAMPfor psql, but without specifying UTC this returns the server's local time.SQLAlchemy docs recommend the following implementation for a psql utc_now():