我正在尝试从 迁移cx_Oracle 8.1.0
到oracledb 2.5.1
库。之前这样的查询是有效的:
update command_center set
E_ID = :1,
E_ASPECTS = :2,
E_CREATED_TIMESTAMP = :3
WHERE e_id = :1
def bulk_insert_or_update_data_to_targets(self, sql, target_data, id_index=0):
for target_connections, data in target_data:
for con in target_connections:
cursor = con.cursor()
cursor.executemany(sql, data, batcherrors=True)
if cursor.getbatcherrors():
self.logger.debug("data: " + str(data))
cursor.close()
但目前我有以下例外:
oracledb.exceptions.DatabaseError: DPY-4009: 4 positional bind values are required but 3 were provided
这是否有可能像以前一样工作cx_Oracle
...所以我猜它是通过数组索引检索属性的?
后者是首选,因为它不会遇到您看到的问题。即使是 Thick 模式也与按位置绑定存在一些差异,这取决于您使用的是 SQL 还是 PL/SQL 语句。
我认为问题可能是由于
:1
在查询中使用了两次。您不需要在子句
E_ID = :1
中SET
,因为您要将列设置为它已经具有的相同值(因为WHERE E_ID = :1
)。因此删除它: