So helpful! Thanks.
*Randy Syring*
Chief Executive Developer
Direct: 502.276.0459
Office: 812.285.8766
Level 12 <https://www.level12.io/>
On 07/24/2015 03:45 PM, Mike Bayer wrote:
On 7/24/15 3:17 PM, Randy Syring wrote:
I have some generic timestamp columns as part of a mixin. I'd like
for these columns to have server defaults of the current UTC time.
If I wanted local time, I could just do:
created_ts = Column(DateTime, ...,
server_default=sasql.text('CURRENT_TIMESTAMP'))
The problem I'm running into is that the DB servers all have a
different way of getting UTC time:
SQLITE: select CURRENT_TIMESTAMP
Microsoft SQL: select GETUTCDATE()
PostgreSQL: select (now() at time zone 'utc')
So how do I set the server default in a db specific way when I want
to be able to define the columns in a library that will be used on
different DB servers?
yup this is a common one, so much that here it is right here:
http://docs.sqlalchemy.org/en/rel_1_0/core/compiler.html#utc-timestamp-function
--
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+unsubscr...@googlegroups.com
<mailto:sqlalchemy+unsubscr...@googlegroups.com>.
To post to this group, send email to sqlalchemy@googlegroups.com
<mailto:sqlalchemy@googlegroups.com>.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to a topic in the
Google Groups "sqlalchemy" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/sqlalchemy/NpK5n59QbV8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
sqlalchemy+unsubscr...@googlegroups.com
<mailto:sqlalchemy+unsubscr...@googlegroups.com>.
To post to this group, send email to sqlalchemy@googlegroups.com
<mailto:sqlalchemy@googlegroups.com>.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.
--
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+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.