Skip to main content
Solved

How to use current system time in Python shutdown script?

  • Mar 11, 2016 1:32 AM UTC
  • 2 replies
  • 95 views

dbCursor.execute("""INSERT INTO FME_LOG(NAME, RUN_DATE) VALUES ('eee', datetime.datetime.now())""") is not working.

Best answer by david_r

Hi

If it's Oracle, you can use the built-in SYSDATE function to return the current timestamp without having to wrestle with Python datetime objects:

insert into fme_log(name, run_date) values ('eee', sysdate)

The equivalent to SYSDATE on MS SQL Server is "sysdatetime()" and on PostgreSQL it is "current_timestamp".

David

View original
This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

2 replies

david_r
Celebrity
  • Best Answer
  • Mar 11, 2016 8:22 AM UTC

Hi

If it's Oracle, you can use the built-in SYSDATE function to return the current timestamp without having to wrestle with Python datetime objects:

insert into fme_log(name, run_date) values ('eee', sysdate)

The equivalent to SYSDATE on MS SQL Server is "sysdatetime()" and on PostgreSQL it is "current_timestamp".

David


Forum|alt.badge.img+5
  • Mar 11, 2016 10:57 AM UTC

Hi

If it's Oracle, you can use the built-in SYSDATE function to return the current timestamp without having to wrestle with Python datetime objects:

insert into fme_log(name, run_date) values ('eee', sysdate)

The equivalent to SYSDATE on MS SQL Server is "sysdatetime()" and on PostgreSQL it is "current_timestamp".

David

Note that sysdate is the timestamp of the database server. This might be different from the timestamp of the client where you're running FME, which is the timestamp Python would give you. Sysdate is probably the one you want though.