on ‎2024 May 10 8:07 AM
Hi, I don't know why the `executemany()` calls of Python hdbcli library returns -2 rather than 0.
cursor.execute("CREATE TABLE PERSON ( ID INTEGER, NAME NVARCHAR(50), AGE INTEGER, CITY NVARCHAR(50), PRIMARY KEY (ID, NAME) )")
print("INSERT ===")
ret_count = cursor.executemany("INSERT INTO PERSON VALUES (?, ?, ?, ?)", [[1, 'Jack', 15, 'SF']])
print(ret_count)
print("UPDATE ===")
ret_count = cursor.executemany("UPDATE PERSON SET AGE = 25 WHERE NAME = ? AND ID = ?", [['Jack', 1]]) # ok
print(ret_count)
ret_count = cursor.executemany("UPDATE PERSON SET AGE = 25 WHERE NAME = ? AND ID = ?", [['Jack', 2]]) # partial match
print(ret_count)
ret_count = cursor.executemany("UPDATE PERSON SET AGE = 25 WHERE NAME = ? AND ID = ?", [['Anna', 3]]) # none of them
print(ret_count)
print("DELETE ===")
ret_count = cursor.executemany("DELETE FROM PERSON WHERE ID = ? AND NAME = ?", [[1, 'Anna']]) # partial match
print(ret_count)
ret_count = cursor.executemany("DELETE FROM PERSON WHERE ID = ? AND NAME = ?", [[1, 'Jack']]) # ok
print(ret_count)
ret_count = cursor.executemany("DELETE FROM PERSON WHERE ID = ? AND NAME = ?", [[1, 'Jack']]) # none of themIt's output is,
INSERT ===
(1,)
UPDATE ===
(1,)
(-2,)
(-2,)
DELETE ===
(-2,)
(1,)
(-2,)I did in the latest version, hdbcli==2.20.15. Could you explain the reason? Thank you!
Request clarification before answering.
One option may be to use the code below:
ret_count = cursor.executemany("DELETE FROM PERSON WHERE ID = ? AND NAME = ?", [[1, 'Jack']], batcherrors=True) # ok
print(cursor.getrowsaffectedcounts())See also getrowsaffectedcounts() Method.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 15 | |
| 9 | |
| 6 | |
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.