---
title: batch
sidebarTitle: batch
---

# `pdsx._internal.batch`


batch operations for concurrent CRUD operations.

## Functions

### `batch_delete` <sup><a href="https://github.com/zzstoatzz/pdsx/blob/main/src/pdsx/_internal/batch.py#L41" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python
batch_delete(client: AsyncClient, uris: list[str]) -> BatchResult
```


delete multiple records concurrently.

**Args:**
- `client`: authenticated atproto client
- `uris`: list of record URIs to delete
- `concurrency`: maximum concurrent operations (default\: 10)
- `fail_fast`: stop on first error (default\: False)
- `show_progress`: show progress bar (default\: True)

**Returns:**
- batch result with successful and failed operations


### `batch_create` <sup><a href="https://github.com/zzstoatzz/pdsx/blob/main/src/pdsx/_internal/batch.py#L106" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python
batch_create(client: AsyncClient, collection: str, records: list[dict[str, RecordValue]]) -> BatchResult
```


create multiple records concurrently.

**Args:**
- `client`: authenticated atproto client
- `collection`: collection name
- `records`: list of record data dictionaries
- `concurrency`: maximum concurrent operations (default\: 10)
- `fail_fast`: stop on first error (default\: False)
- `show_progress`: show progress bar (default\: True)

**Returns:**
- batch result with successful URIs and failed operations


### `batch_update` <sup><a href="https://github.com/zzstoatzz/pdsx/blob/main/src/pdsx/_internal/batch.py#L176" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python
batch_update(client: AsyncClient, updates: list[tuple[str, dict[str, RecordValue]]]) -> BatchResult
```


update multiple records concurrently.

**Args:**
- `client`: authenticated atproto client
- `updates`: list of (uri, updates_dict) tuples
- `concurrency`: maximum concurrent operations (default\: 10)
- `fail_fast`: stop on first error (default\: False)
- `show_progress`: show progress bar (default\: True)

**Returns:**
- batch result with successful URIs and failed operations


### `read_uris_from_stdin` <sup><a href="https://github.com/zzstoatzz/pdsx/blob/main/src/pdsx/_internal/batch.py#L241" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python
read_uris_from_stdin() -> list[str]
```


read URIs from stdin, one per line.

**Returns:**
- list of URIs read from stdin


### `read_records_from_stdin` <sup><a href="https://github.com/zzstoatzz/pdsx/blob/main/src/pdsx/_internal/batch.py#L253" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python
read_records_from_stdin() -> list[dict[str, RecordValue]]
```


read JSONL records from stdin, one JSON object per line.

**Returns:**
- list of record dictionaries parsed from JSONL

**Raises:**
- `ValueError`: if JSON parsing fails


### `read_updates_from_stdin` <sup><a href="https://github.com/zzstoatzz/pdsx/blob/main/src/pdsx/_internal/batch.py#L285" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python
read_updates_from_stdin() -> list[tuple[str, dict[str, RecordValue]]]
```


read JSONL update records from stdin.

each line should be a JSON object with a 'uri' field and update fields.

**Returns:**
- list of (uri, updates_dict) tuples

**Raises:**
- `ValueError`: if JSON parsing fails or uri field is missing


### `display_batch_result` <sup><a href="https://github.com/zzstoatzz/pdsx/blob/main/src/pdsx/_internal/batch.py#L330" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python
display_batch_result(result: BatchResult, operation: str = 'deleted') -> None
```


display batch operation results.

**Args:**
- `result`: batch operation result
- `operation`: operation name for display (e.g., "deleted", "updated")


## Classes

### `BatchResult` <sup><a href="https://github.com/zzstoatzz/pdsx/blob/main/src/pdsx/_internal/batch.py#L24" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>


result of a batch operation.


**Methods:**

#### `total` <sup><a href="https://github.com/zzstoatzz/pdsx/blob/main/src/pdsx/_internal/batch.py#L31" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python
total(self) -> int
```

total operations attempted.


#### `success_rate` <sup><a href="https://github.com/zzstoatzz/pdsx/blob/main/src/pdsx/_internal/batch.py#L36" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python
success_rate(self) -> float
```

success rate as percentage.

