Forum Stats

  • 3,770,291 Users
  • 2,253,091 Discussions
  • 7,875,393 Comments

Discussions

Timestamp data type and bulk insert

_AZ_
_AZ_ Member Posts: 494
edited Oct 11, 2017 6:52PM in Python

My previous question got me wondering, how would i go about inserting multiple rows with timestamp values?

Lets say, i have a few million records to insert. I store them in a list. And let's say, one "column" in the list is a timestamp with miliseconds information.

Appreciate

Answers

  • Anthony Tuininga-Oracle
    Anthony Tuininga-Oracle Member Posts: 37 Employee
    edited Oct 11, 2017 6:52PM

    I'm not completely certain of what you are asking. It might be helpful to include some sample code, like the following:

    someData = [

       (1, "String", datetime.datetime(2017, 10, 11), datetime.datetime(2017, 10, 12, 15, 30, 12, 156000)),

       (2, "Another string", datetime.datetime(2017, 5, 6), datetime.datetime(2017, 5, 7, 12, 25, 13, 387000))

    ]

    cursor.executemany("insert into SomeTable (NumCol, StrCol, DateCol, TimestampCol) values (:1, :2, :3, :4)", someData)

    That should work just fine. If I misunderstood what you were trying to ask, please let me know!

This discussion has been closed.