Skip to content

Commit

Permalink
fix on rethinkdb
Browse files Browse the repository at this point in the history
  • Loading branch information
phenobarbital committed Oct 24, 2024
1 parent a3e8ab3 commit bb0a447
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion asyncdb/drivers/rethink.py
Original file line number Diff line number Diff line change
Expand Up @@ -713,13 +713,19 @@ async def write(
if isinstance(data, list) and len(data) > batch_size:
# Handle batch insertion for large lists
for start in range(0, len(data), batch_size):
self._logger.debug(
f"Rethink: Saving batch {start + 1} to {start + batch_size} of {len(data)} records"
)
batch = data[start:start + batch_size]
result = await self._batch_insert(table, batch, on_conflict, changes, durability)
if result["errors"] > 0:
raise DriverError(
f"INSERT Error in batch: {result['first_error']}"
)
return {"inserted": len(data), "batches": (len(data) + batch_size - 1) // batch_size}
return {
"inserted": len(data),
"batches": (len(data) + batch_size - 1) // batch_size
}
else:
result = await self._batch_insert(table, data, on_conflict, changes, durability)
if result["errors"] > 0:
Expand Down

0 comments on commit bb0a447

Please sign in to comment.