cx_Oracle.Cursor.bindarraysize 的正确设置

Correct Setting for cx_Oracle.Cursor.bindarraysize

我发现一些关于 cx_Oracle 中 Cursor.bindarraysize 属性的正确设置的一些相互矛盾的文档。

cx-oracle.readthedocs

This read-write attribute specifies the number of rows to bind at a time and is used when creating variables via setinputsizes() or var(). It defaults to 1 meaning to bind a single row at a time.

Documentation for the database 以不同方式描述绑定数组大小:

The bind array's size is equivalent to the number of rows it contains times the maximum length of each row. The maximum length of a row equals the sum of the maximum field lengths, plus overhead, as follows:

我倾向于相信前者,因为当您调用 Cursor.setinputsizes 时,Python API 可能正在执行该计算,但有人可以证实或否定这种信念吗?

cx_Oracle 文档关于 cx_Oracle 的工作方式是正确的。该值指定一次可以绑定的行数。值 1 适用于所有情况,但调用 executemany() 的情况除外。我考虑过删除这个值,因为无论如何你都可以在创建变量时指定大小(使用参数 arraysize),如果你不这样做,它会在检测到多行被绑定时自动调整变量大小。