Re: [cx-oracle-users] which row is causing problem ? (with executemany and cx_Oracle.DatabaseError)
Brought to you by:
atuining
From: Anthony T. <ant...@gm...> - 2011-10-20 16:04:55
|
Hi, On the error object there is an "offset" value which will give you that information. Also, the rowcount is set to the number of rows that were successfully processed if I recall correctly. Anthony On Thu, Oct 20, 2011 at 7:49 AM, Quiche Obscure <qui...@gm...> wrote: > 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 ? > > ------------------------------------------------------------------------------ > The demand for IT networking professionals continues to grow, and the > demand for specialized networking skills is growing even more rapidly. > Take a complimentary Learning@Ciosco Self-Assessment and learn > about Cisco certifications, training, and career opportunities. > http://p.sf.net/sfu/cisco-dev2dev > _______________________________________________ > cx-oracle-users mailing list > cx-...@li... > https://lists.sourceforge.net/lists/listinfo/cx-oracle-users > > |