解决方法
cx_Oracle 版本 < 7.1
- perform all inserts in a single batch (but depending on size this might not be usable)
- create a new cursor for each batch (so that cx_Oracle calculates the types for each batch)
- use cursor.setinputsizes() to specify the types and sizes (may be cumbersome)
db_types = (d[1] for d in cursor_select.description)
cursor_insert.setinputsizes(*db_types)
cx_Oracle 版本 >= 7.1
该 bug 已被修复。
但又会有新的 bug:
"DPI-1044: value cannot be represented as an Oracle number", // DPI_ERR_NUMBER_NO_REPR
暂且没找到解决方法,那还是用旧版的先吧。。
参考
cx_Oracle github issue
cx_Oracle - dynamic cursor.setinputsizes