Forum Stats

  • 3,769,895 Users
  • 2,253,029 Discussions
  • 7,875,233 Comments

Discussions

How do we insert dates using executemany in Python+cx_Oracle ?

288ba680-a18f-43a1-a266-706542318532
edited Dec 5, 2017 6:29AM in Python

Hello,

I am using Oracle 11g and Python 2.7 to insert data into my tables.

I have a list of dictionaries - example [ {"Date": "12/12/2012" , "CheckStatement" : "Yes"} , {"Date": "13/12/2012" , "CheckStatement" : "Yes"}]

I make a list of lists out it- example [["11/11/2017 5:06", "Yes"], ["11/11/2017 5:06", "Yes"]]

My DB table looks like -

Date (TIMESTAMP(6))
CheckStatement (String)
11/11/2017 5:06Yes
11/11/2017 5:06No
11/11/2017 5:06Yes

How do I execute the executemany() function so that my dates are filled with it?

Currently i get this error - ORA-01843: not a valid month

Answers

  • SeánMacGC
    SeánMacGC Member Posts: 2,914 Gold Trophy
    edited Dec 5, 2017 6:29AM

    Hello, could you try with the ANSI date format, ie, 'YYYY-MM-DD' , so see if that avoids the error?

    And, additionally, the ANSI date timestamp format would be: 'YYYY-MM-DD HH24:MI:SS.FFFFFF'.

This discussion has been closed.