Choose a write operation
Appending the same input twice can create duplicate records. Use merge insert
with a stable key when the incoming data should update existing records.
Connect and prepare the data
Use the connection guide to connect to Embedded or Enterprise. The SDK write operations in this section work with both. Enterprise also supports SQL write statements; an SDK filter expression does not require a separate SQL connection. Choose the column types, required fields and vector dimensions before a large load. SDKs support different input representations, including row objects and Arrow batches. The table creation guide covers those choices.Try a complete write workflow
This example starts with Alice and Bob, appends Charlie, updates Bob’s name and login count, then merges a batch containing Charlie and Dana. Finally, it selects Dana’s row for inspection and deletes it.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.