[cx-oracle-users] Re : Re: which row is causing problem ? (with executemany and cx_Oracle.DatabaseE
Brought to you by:
atuining
From: <qui...@gm...> - 2011-10-20 19:06:15
|
Thank you for your reply.<br>I'll try this offset tomorrow (it is the evening where I leave) <br><span style="font-family:Prelude, Verdana, san-serif;"><br><br></span><span id="signature"><div style="font-family: arial, sans-serif; font-size: 12px;color: #999999">-- Envoyé depuis mon HP TouchPad</div></span><span style="color:navy; font-family:Prelude, Verdana, san-serif; "><hr align="left" style="width:75%">Le 20 oct. 2011 18:05, Anthony Tuininga <ant...@gm...> a écrit : <br></span>Hi, <br> <br>On the error object there is an "offset" value which will give you <br>that information. Also, the rowcount is set to the number of rows that <br>were successfully processed if I recall correctly. <br> <br>Anthony <br> <br>On Thu, Oct 20, 2011 at 7:49 AM, Quiche Obscure <br><qui...@gm...> wrote: <br>> Hello, <br>> <br>> I am trying to import millions of rows in a table with executemany. <br>> <br>> Fiew of them are rejected by oracle because of various problems (not null <br>> constraint, format number ...). <br>> <br>> If I do this : <br>> <br>> ################################################################## <br>> insert = """ INSERT INTO mytable (col1,col2,col3) VALUES (:1, :2, :3)""" <br>> L = [] <br>> reader = csv.reader(open(infile), delimiter=';') <br>> i=0 <br>> for row in reader: <br>> L.append(row) <br>> if(i>10000): <br>> try: <br>> cursor.prepare(insert) <br>> cursor.executemany(None, L) <br>> cursor.commit() <br>> i=0 <br>> except cx_Oracle.DatabaseError,exc: <br>> error, = exc.args <br>> mess="\nOracle-Error-Code:"+str(error.code) <br>> mess+="\nOracle-Error-Message:"+str(error.message) <br>> mess+="\nOracle-Error-context:"+str(error.context) <br>> mess+="\nTOUS:"+str(exc) <br>> sys.exit(mess) <br>> i+=1 <br>> <br>> ################################################################## <br>> <br>> I don't know the way to find out in the DatabaseError which row is causing <br>> the exception. <br>> <br>> Any idea ? <br>> <br>> ------------------------------------------------------------------------------ <br>> The demand for IT networking professionals continues to grow, and the <br>> demand for specialized networking skills is growing even more rapidly. <br>> Take a complimentary Learning@Ciosco Self-Assessment and learn <br>> about Cisco certifications, training, and career opportunities. <br>> http://p.sf.net/sfu/cisco-dev2dev <br>> _______________________________________________ <br>> cx-oracle-users mailing list <br>> cx-...@li... <br>> https://lists.sourceforge.net/lists/listinfo/cx-oracle-users <br>> <br>> <br> <br>------------------------------------------------------------------------------ <br>The demand for IT networking professionals continues to grow, and the <br>demand for specialized networking skills is growing even more rapidly. <br>Take a complimentary Learning@Ciosco Self-Assessment and learn <br>about Cisco certifications, training, and career opportunities. <br>http://p.sf.net/sfu/cisco-dev2dev <br>_______________________________________________ <br>cx-oracle-users mailing list <br>cx-...@li... <br>https://lists.sourceforge.net/lists/listinfo/cx-oracle-users |