Skip to main content
Use add() to append records to an existing table. It does not compare incoming keys with stored keys. Choose merge insert when the same record may arrive again and should update an existing row.

Append a first batch

Install the Python SDK with pip install lancedb. This complete example starts with Alice, appends Bob and Charlie, and prints all three records.
append_rows.py
The program uses temporary local storage. For a complete TypeScript or Rust example, see Complete write workflow. Enterprise SQL offers INSERT, including INSERT ... SELECT.

Prepare the input

Match the table’s schema, including required fields and vector dimensions. Supported input formats differ by SDK; see Create a table. Inspect conversion errors before retrying, and verify the final row count and representative values.

Choose input for a large load

Avoid building one large in-memory list when records already live in files or arrive as batches. Create a table with the intended schema, then append through the appropriate input path.

Read from files

Python accepts a pyarrow.dataset.Dataset. This example writes a small Parquet file locally, creates an empty table with its schema, and appends the two records. For your own data, point the dataset reader at the input files instead.
load_parquet.py
A file-backed source can be scanned without first loading the whole dataset into application memory. This Python input API is distinct from converting files to Arrow batches yourself in another language.

Produce batches during ingestion

Use batches when processing the input as it arrives. The Python example creates an empty table and appends ten records produced by a batch iterator.
The language APIs differ: the TypeScript example appends each constructed Arrow batch, while the Rust example supplies an Arrow reader when creating the table. These are input-format examples, not equivalent parallel-write benchmarks.

Control write parallelism

Python’s add() can estimate parallelism for materialized inputs. A streaming reader may not expose its total size or support replay. Use write_parallelism when controlling the number of concurrent partitions; increasing it can also increase memory use. TypeScript does not expose that manual option. Measure with realistic row sizes and storage. Avoid one write per row when a batch will do, and avoid a large worker count for a small input.

Track completion and progress

Python, TypeScript and Rust support progress callbacks when adding data. These examples start with Alice, append Bob and Charlie, and print the number of rows written as progress updates arrive. After the write succeeds, they query the table to show all three records. Each program uses a temporary local database and removes it when finished.
  • Python: install lancedb, save the code as insert_progress.py, and run python insert_progress.py.
  • TypeScript: install @lancedb/lancedb, save the code as insert_progress.mts, and run node insert_progress.mts with Node.js 22.18 or later.
  • Rust: download the Rust examples, extract the project, and run cargo run --locked --bin progress.
For a progress bar in Python, install tqdm and pass progress=True instead of a callback.

Read progress updates

Updates include row and byte counts, elapsed time, and parallel write activity. The field names differ by language: Python and TypeScript report elapsed time in seconds; Rust returns a Duration. The expected row count may be unknown for streaming input. On the final update, it falls back to the number of rows written. Keep callbacks short and use the write operation’s result to determine success. The final done update means progress reporting has ended; it can also occur after a write fails or is cancelled. Input errors before writing starts may produce no updates. TypeScript delivers callbacks asynchronously. Slow callbacks can queue up, and the add() promise may resolve before every callback has run. Exceptions from a TypeScript callback are logged and do not abort the write.

Verify writes and handle retries

Wait for the write operation’s result, then check the expected records. Progress callbacks describe activity; they do not establish that a write succeeded. A timeout or connection error can leave a write still running or committed with its response lost. Do not automatically repeat the whole add() call: an append can duplicate rows. A request ID helps trace the attempt; it is not an idempotency key. Check the installed SDK’s retry behavior too. For example, the Python and TypeScript 0.40.0 clients can resend an Enterprise append after a 504 even when it already committed. Resolve the original attempt before reconciling a fresh snapshot using stable application keys. Missing rows in an immediate query do not prove that the original write cannot commit later; changing to an upsert does not stop that earlier append.

Configure large uploads

Enterprise For LanceDB Enterprise tables (db:// connections), a large write can use multipart upload. The SDK stages parts under an upload ID before committing the write. Multipart selection and retry behavior depend on the installed SDK; these settings do not affect LanceDB Embedded writes. A large part can exceed the client read timeout while uploading and writing to object storage:
The SDK source pinned by Enterprise 1.12.0 is 0.42.0-beta.8. Its multipart settings have the defaults below; newer SDKs can have different defaults and retry protections. These are client settings, not server request limits, and apply only when the SDK uses multipart upload. A part is cut between input batches after either target is reached. The duration setting triggers a cut in the streamed request body; it does not change the HTTP request deadline. Lower the byte target and use smaller input batches when large uploads hit the read timeout. For Blob data, size caller batches by payload bytes rather than row count, and allow for Arrow encoding overhead and the application’s live buffers. A single Blob value is not split by lowering the multipart target; choose an explicit chunk representation only if the application can reconstruct it. Blob storage packing thresholds are separate from upload budgets.
Uploaded parts and progress updates are not a final table commit. Wait for the write result. A new add() call can start a different upload; it does not replay a part from the previous attempt. Follow the retry guidance when a write’s outcome is unknown.

Complete write workflow

Each program creates a temporary local database, performs the five operations, prints the result, and removes its temporary data when finished.
  • Python: install lancedb, save the code as ingestion.py, and run python ingestion.py.
  • TypeScript: install @lancedb/lancedb, save the code as ingestion.mts, and run node ingestion.mts with Node.js 22.18 or later.
  • Rust: download the complete Rust project, extract it, and run cargo run --locked. It includes src/main.rs, the Cargo manifest and a lockfile for the example’s dependencies. The code is shown below.
After the operations, Alice has 10 logins, Bobby has 21, and Charlie has 6. Dana is selected for deletion and is absent from the final result.