Reliable data imports

Small import jobs are easier to inspect when every step has an explicit boundary. This guide describes a repeatable path from source selection to a verified result.

Prepare a source

Read the input as a stream when its size is unknown. Preserve the source identifier and record a checksum before transforming any fields.

with source.open("rb") as stream:
    digest = checksum(stream)
    rows = parse_records(stream)

See stream handling for the supported interfaces.

Validate records

Validate required fields before writing. Keep row-level errors with their input positions so an operator can correct the source without guessing.

for position, row in enumerate(rows, start=1):
    validate(row, source_row=position)

strict=True stops on the first invalid record; the default collects a bounded set of errors.

Retry safely

Retries are useful for temporary storage failures, but repeating a write can duplicate records. Use an idempotency key and keep the commit step separate from parsing.

Transaction guidance