Skip to main content
Solved

How to use current system time in Python shutdown script?


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
Did this help you find an answer to your question?

2 replies

david_r
Evangelist
  • Best Answer
  • March 11, 2016

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
  • March 11, 2016
david_r wrote:

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.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings