Ahmed Malabi
Ahmed Malabi

Reputation: 1

Python cx_oracle Cursor.executemany() error - Type Error expecting a number

I am running in to an issue when tryin to run the executemany function. When attempting to insert the rows all together, Type Error is being thrown by Cursor.executeMany stating that a number is expected.

Having an issue with executemany before I tried adding the argument batcherrors=True to the function call but it is still throwing the error.

Sample code:

sql_statement = "insert into table (x, y, z) values (:x, :y, :z)"
cursor.prepare(sql_statement)
cursor.executemany(None, rows_to_be_inserted, batcherrors=True)
for error in Cursor.getbatcherrors()
  print(error.message)

The for loop is never reached as cursor.executemany(None, rows_to_be_inserted, batcherrors=True) throws an error.

However when running the following code, all lines are successfully inserted into the DB

sql_statement = "insert into table (x, y, z) values (:x, :y, :z)"
for row in rows_to_be_inserted:
  cursor.execute(sql_statement, row)

Upvotes: 0

Views: 79

Answers (0)

Related Questions