rikirolly commented on issue #28329:
URL: https://github.com/apache/airflow/issues/28329#issuecomment-1487088742

   I have seen in sqlachemy documentation they suggest this:
   ```"UTC timestamp" function
   -------------------------
   
   A function that works like "CURRENT_TIMESTAMP" except applies the
   appropriate conversions so that the time is in UTC time.   Timestamps are 
best
   stored in relational databases as UTC, without time zones.   UTC so that your
   database doesn't think time has gone backwards in the hour when daylight
   savings ends, without timezones because timezones are like character
   encodings - they're best applied only at the endpoints of an application
   (i.e. convert to UTC upon user input, re-apply desired timezone upon 
display).
   
   For PostgreSQL and Microsoft SQL Server::
   
       from sqlalchemy.sql import expression
       from sqlalchemy.ext.compiler import compiles
       from sqlalchemy.types import DateTime
   
       class utcnow(expression.FunctionElement):
           type = DateTime()
           inherit_cache = True
   
       @compiles(utcnow, 'postgresql')
       def pg_utcnow(element, compiler, **kw):
           return "TIMEZONE('utc', CURRENT_TIMESTAMP)"
   
       @compiles(utcnow, 'mssql')
       def ms_utcnow(element, compiler, **kw):
           return "GETUTCDATE()"
   
   Example usage::
   
       from sqlalchemy import (
                   Table, Column, Integer, String, DateTime, MetaData
               )
       metadata = MetaData()
       event = Table("event", metadata,
           Column("id", Integer, primary_key=True),
           Column("description", String(50), nullable=False),
           Column("timestamp", DateTime, server_default=utcnow())
       )
   `
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to