how to create timestamp without time zone column with postgresql

1,603 views
Skip to first unread message

Yingchen Zhang

unread,
Jul 23, 2018, 2:01:07 PM7/23/18
to sqlalchemy
data type TIMESTAMP just have one param is timezone and it's use server timezone setting.

how to create a `timestamp without time zone` column with postgresql ?

code:

Column('created_at', TIMESTAMP(False), nullable=False, server_default=text('now()'))




Ruben Di Battista

unread,
Jul 23, 2018, 2:04:24 PM7/23/18
to sqlal...@googlegroups.com
What about using DateTime type?

          _   
-.     .´  |∞∞∞∞
  ',  ;    |∞∞∞∞∞∞
    ˜˜     |∞∞∞∞∞∞∞∞∞ RdB
    ,.,    |∞∞∞∞∞∞
  .'   '.  |∞∞∞∞
-'       `’

http://rdb.is
--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
 
http://www.sqlalchemy.org/
 
To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description.
---
You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+...@googlegroups.com.
To post to this group, send email to sqlal...@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Mike Bayer

unread,
Jul 23, 2018, 2:10:16 PM7/23/18
to sqlal...@googlegroups.com
passing timezone=False will render as "TIMESTAMP WITHOUT TIME ZONE" on
postgresql:

>>> from sqlalchemy import TIMESTAMP
>>> from sqlalchemy.dialects import postgresql
>>> print(TIMESTAMP(timezone=False).compile(dialect=postgresql.dialect()))
TIMESTAMP WITHOUT TIME ZONE


as will the way you have it w/o the name:

>>> print(TIMESTAMP(False).compile(dialect=postgresql.dialect()))
TIMESTAMP WITHOUT TIME ZONE

Yingchen Zhang

unread,
Jul 23, 2018, 4:04:52 PM7/23/18
to sqlalchemy
If set timezone=False, the value should be UTC time ?
I inserted a new line to database , it's used server timezone : PRC

在 2018年7月24日星期二 UTC+8上午2:10:16,Mike Bayer写道:

Mike Bayer

unread,
Jul 23, 2018, 6:21:42 PM7/23/18
to sqlal...@googlegroups.com
you should make sure that datetime objects you put in there are
against your local UTC time first.
Reply all
Reply to author
Forward
0 new messages