[cx-oracle-users] insert using executemanyprepared
Brought to you by:
atuining
From: Chris D. <cdu...@ya...> - 2005-03-19 14:17:34
|
All, Upto now I've been using executemany to bulk insert data. Upto 4.0.1 this has been fine but now with 4.1.0 it doesn't seem to work with RAW columns, see below for a simple example: import cx_Oracle db1 = cx_Oracle.connect("regt/test@sxl920d2") cur1 = db1.cursor() cur1.execute("select * from binary_source") data = cur1.fetchall() listDict = [] for row in data: tempDict = {} x = 1 for item in row: tempDict["arg" + str(x)] = item x = x + 1 listDict.append(tempDict) curInsert = db1.cursor() curInsert.setinputsizes( arg1 = cx_Oracle.NUMBER, arg2 = cx_Oracle.BINARY, arg3 = cx_Oracle.NUMBER) insStr = "insert into WAREHOUSES_STOCK (PRODUCT_ID,WAREHOUSE_ID,QUANTITY_ON_HAND) values (:arg1,:arg2,:arg3)" curInsert.prepare(insStr) curInsert.executemany(insStr, listDict) This gives the following error using 4.1.0, works OK for 4.0.1 (Oracle 9.2 on Linux): Traceback (most recent call last): File "binary2.py", line 19, in ? curInsert.executemany(insStr, listDict) cx_Oracle.DatabaseError: ORA-01465: invalid hex number As I'm concerned about performance I've look at using executemanyprepared (looked at copydata.py in cx_OracleTools) but haven't managed to get it to work. Pls does someone have a simple step-by-step example of using executemanyprepared with an insert that could be used in my example above to replace the executemany. Thanks very much, Chris __________________________________ Do you Yahoo!? Yahoo! Sports - Sign up for Fantasy Baseball. http://baseball.fantasysports.yahoo.com/ |