2

I have the following table I'm creating. After running this in a script to populate a database, the created_at columns come back with a value of "2018-10-24 19:47:22.60331".

I'm not getting the time zone offset even though https://www.postgresql.org/docs/9.2/static/functions-datetime.html#FUNCTIONS-DATETIME-CURRENT shows that function as adding the time zone offset.

def simulation_version_metadata(metadata):
    simulation_version = Table('simulation_version', metadata,
                               Column('id', Integer, primary_key=True),
                               Column('simulation_id', None,
                                      ForeignKey('simulation.id')),
                               Column('created_at', DateTime,
                                      server_default=func.current_timestamp()),
                               Column('updated_at', DateTime,
                                      server_default=func.current_timestamp()),
                               )
    return simulation_version

1 Answer 1

3

DateTime columns in SQLAlchemy default to timezone=False. Set timezone=True like:

Column('created_at', DateTime(timezone=True), server_default=func.current_timestamp())
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.