[cx-oracle-users] which row is causing problem ? (with executemany and cx_Oracle.DatabaseError)
Brought to you by:
atuining
From: Quiche O. <qui...@gm...> - 2011-10-20 13:49:19
|
Hello, I am trying to import millions of rows in a table with executemany. Fiew of them are rejected by oracle because of various problems (not null constraint, format number ...). If I do this : ################################################################## insert = """ INSERT INTO mytable (col1,col2,col3) VALUES (:1, :2, :3)""" L = [] reader = csv.reader(open(infile), delimiter=';') i=0 for row in reader: L.append(row) if(i>10000): try: cursor.prepare(insert) cursor.executemany(None, L) cursor.commit() i=0 except cx_Oracle.DatabaseError,exc: error, = exc.args mess="\nOracle-Error-Code:"+str(error.code) mess+="\nOracle-Error-Message:"+str(error.message) mess+="\nOracle-Error-context:"+str(error.context) mess+="\nTOUS:"+str(exc) sys.exit(mess) i+=1 ################################################################## I don't know the way to find out in the DatabaseError which row is causing the exception. Any idea ? |