I have a SQLAlchemy table that is defined
foo_table = Table('foo', metadata, Column('id', Integer, primary_key=True), Column('created_on', DateTime, default=func.now()), ... )
which creates a table in Postgres
CREATE TABLE foo ( id serial NOT NULL, created_on timestamp without time zone, ... )
The local time zone is set correctly (it is verified that Python datetime.datetime.now() displays my local time), but whenever I insert a line into foo_table without explicitly setting created_on , the time is used for the current UTC instead of my local time (for example, "2015-07-29 16: 38: 08.112192").
When I try to set created_on manually, it all works fine, but Postgres or SQLAlchemy seems to convert the time to UTC, leaving it to func.now() to assign a timestamp.
How can I get SQLAlchemy or Postgres to simply create a record with my current local time?
source share