Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions bindings/python/decentdb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2806,7 +2806,10 @@ def executemany(self, operation, seq_of_parameters):
bind_int64 = self._lib.ddb_stmt_bind_int64
bind_float64 = self._lib.ddb_stmt_bind_float64
bind_text = self._lib.ddb_stmt_bind_text
fetch_stmt_affected_rows = self._lib.ddb_stmt_affected_rows
err_ok = ERR_OK
affected = ctypes.c_uint64()
affected_byref = byref(affected)

def bind_row_fast(params):
for i, param in enumerate(params, start=1):
Expand All @@ -2829,10 +2832,18 @@ def bind_row_fast(params):
if code != err_ok:
_raise_error(code, sql=sql, params=params)

def fetch_affected_rows(params):
code = fetch_stmt_affected_rows(self._stmt, affected_byref)
if code != err_ok:
_raise_error(code, sql=sql, params=params)
return int(affected.value)

total_affected = 0
bind_row_fast(normalized_first)
code = step_stmt(self._stmt, byref(step_out))
if code != ERR_OK:
_raise_error(code, sql=sql, params=normalized_first)
total_affected += fetch_affected_rows(normalized_first)
self._bound_param_count = expected_count

if "?" in operation:
Expand All @@ -2855,6 +2866,7 @@ def bind_row_fast(params):
code = step_stmt(self._stmt, byref(step_out))
if code != ERR_OK:
_raise_error(code, sql=sql, params=params)
total_affected += fetch_affected_rows(params)
else:
for params in iterator:
if isinstance(params, Mapping):
Expand All @@ -2879,6 +2891,7 @@ def bind_row_fast(params):
code = step_stmt(self._stmt, byref(step_out))
if code != ERR_OK:
_raise_error(code, sql=sql, params=params)
total_affected += fetch_affected_rows(params)

count = ctypes.c_size_t()
code = self._lib.ddb_stmt_column_count(self._stmt, ctypes.byref(count))
Expand All @@ -2898,11 +2911,7 @@ def bind_row_fast(params):
self._store_cached_non_query_metadata(sql)
self._query_active = False
self._has_buffered_row = False
affected = ctypes.c_uint64()
code = self._lib.ddb_stmt_affected_rows(self._stmt, ctypes.byref(affected))
if code != ERR_OK:
_raise_error(code, sql=sql, params=None)
self.rowcount = int(affected.value)
self.rowcount = total_affected
return self

def _decode_current_row(self):
Expand Down
Loading