Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

current_timestamp in jython component printing datetime function for cursor.execute

Hi team,

I am trying to feed current_timestamp value (redshift) in sql query inside python cursor, further storing the result into list, however current_timestamp inside select cursor is changing into datetime function and respective values.

cursor.execute('select current_timestamp')
result = cursor.fetchall()
print result

[(datetime.datetime(2019, 3, 11, 13, 38, 33, 658098),)]

Can anyone please guide how I can have just current_timestamp value like ('2019-03-11 17:41:38.211589') , to use this further.


1 Community Answers

Matillion Agent  

Dan D'Orazio —

Hi Ravi -

I think you want something like:

cursor = context.cursor()
cursor.execute("select TO_CHAR(current_timestamp, 'YYYY-MM-DD HH24:MI:SS:US')")
result = cursor.fetchone()

Best -

Post Your Community Answer

To add an answer please login