Tabular writes

session.upsert(dataset) (and insert, update, replace) returns a DataSetWriteBuilder; its bins(...) opens the RowWriteBuilder.

class aerospike_sdk.aio.operations.query.DataSetWriteBuilder[source]

Bases: _DataSetWriteBuilderBase[QueryBuilder]

A write verb scoped to a dataset; bins() opens the row builder.

__init__(qb, op_type, dataset)
bins(bin_name, *bin_names)

Fix the bin names every row supplies values for, in order.

Parameters:
  • bin_name (str) – The first bin name.

  • *bin_names (str) – Further bin names.

Return type:

_RowWriteBuilderBase[TypeVar(_QB, bound= _QueryBuilderBase)]

Returns:

A row builder; add records with _RowWriteBuilderBase.row() or _RowWriteBuilderBase.rows().

Raises:

TypeError – If a bin name is not a string.

Example:

await (
    session.upsert(users).bins("name", "age")
    .row(1, "Tim", 312)
    .row(2, "Bob", 25)
    .execute()
)
class aerospike_sdk.aio.operations.query.RowWriteBuilder[source]

Bases: _RowWriteBuilderBase[QueryBuilder]

Rows of a tabular write, executed on the async runtime.

Reached from session.upsert(dataset).bins(...); see _RowWriteBuilderBase for the row and per-row verbs.

async execute(on_error=None)[source]

Write every row as one batch and return the per-row results.

Parameters:

on_error (Union[ErrorStrategy, Callable[[Key, int, AerospikeError], None], None]) – Optional error strategy or callback; see QueryBuilder.execute().

Return type:

RecordStream

Returns:

RecordStream, one result per row.

Raises:

ValueError – If no row was added.

Example:

stream = await session.upsert(users).bins("name", "age").rows(people).execute()
failed = [r for r in await stream.collect() if not r.is_ok]
stream(on_error=None)[source]

Lazy streaming variant of execute().

Return type:

AwaitableContext[RecordStream]

__init__(qb, op_type, dataset, bin_names)
default_expire_record_after(duration)

TTL, as a timedelta, for every row that sets none of its own.

Return type:

Self

default_expire_record_after_seconds(seconds)

TTL for every row that sets none of its own.

Return type:

Self

default_expire_record_at(when)

Absolute expiry for every row that sets none of its own.

Return type:

Self

default_expiry_from_server_default()

Rows that set no TTL take the namespace default.

Return type:

Self

default_never_expire()

Rows that set no TTL never expire.

Return type:

Self

default_with_no_change_in_expiration()

Rows that set no TTL keep their record’s existing TTL.

Return type:

Self

ensure_generation_is(generation)

Require the most recent row’s record to be at generation when written.

Raises:

ValueError – If generation is <= 0.

Return type:

Self

expire_record_after(duration)

Set the TTL of the most recent row from a timedelta.

Return type:

Self

expire_record_after_seconds(seconds)

Set the TTL of the most recent row; see the write-segment verb of the same name.

Return type:

Self

expire_record_at(when)

Expire the most recent row at an absolute time.

Return type:

Self

expiry_from_server_default()

The most recent row takes the namespace default TTL.

Return type:

Self

never_expire()

The most recent row never expires.

Return type:

Self

row(identifier, *values)

Add one record: its id in the dataset, then one value per bin.

Parameters:
  • identifier (Union[str, int, bytes]) – The record’s user key within the dataset.

  • *values (Any) – One value per bin named in bins(), in the same order.

Return type:

Self

Returns:

self, for the next row or a per-row verb.

Raises:

ValueError – If the value count differs from the bin count.

Example:

.bins("name", "age").row(1, "Tim", 312).row(2, "Bob", 25)
rows(rows)

Add many records from an iterable of (id, *values) sequences.

Parameters:

rows (Iterable[Sequence[Any]]) – Any iterable, a list or a generator alike, whose items are sequences holding the id first and then one value per bin.

Return type:

Self

Returns:

self.

Raises:

ValueError – If any row’s value count differs from the bin count.

Example:

people = [(1, "Tim", 312), (2, "Bob", 25), (3, "Jane", 46)]
await session.upsert(users).bins("name", "age").rows(people).execute()
with_no_change_in_expiration()

Keep the existing TTL of the most recent row’s record.

Return type:

Self

with_txn(txn)

Run every row inside txn, or outside any transaction with None.

Return type:

Self