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 withpip install lancedb. This complete example starts
with Alice, appends Bob and Charlie, and prints all three records.
append_rows.py
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 apyarrow.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
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.Control write parallelism
Python’sadd() 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 asinsert_progress.py, and runpython insert_progress.py. - TypeScript: install
@lancedb/lancedb, save the code asinsert_progress.mts, and runnode insert_progress.mtswith Node.js 22.18 or later. - Rust: download the Rust examples,
extract the project, and run
cargo run --locked --bin progress.
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 wholeadd()
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:
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.
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
Complete examples: create, append, update, upsert and delete
Complete examples: create, append, update, upsert and delete
Each program creates a temporary local database, performs the five operations,
prints the result, and removes its temporary data when finished.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.
- Python: install
lancedb, save the code asingestion.py, and runpython ingestion.py. - TypeScript: install
@lancedb/lancedb, save the code asingestion.mts, and runnode ingestion.mtswith Node.js 22.18 or later. - Rust: download the complete Rust project,
extract it, and run
cargo run --locked. It includessrc/main.rs, the Cargo manifest and a lockfile for the example’s dependencies. The code is shown below.