diesel::insert_into. This is Diesel’s portable insert builder on the DuckDB backend.
Single row
Pass a tuple ofcolumn.eq(value) assignments to .values(...):
.execute returns the affected-row count as usize.
Batch insert
Pass a slice of value tuples. DuckDB inserts them in one statement:Inserting structs
A#[derive(Insertable)] struct becomes a value set. Fields map to columns by name:
Insertable.
Columns typed with a DuckDB-specific
Duck* SQL type cannot be inserted through this typed builder —
they bind via diesel::sql_query(...).bind::<DuckXxx, _>(value). See
Type mapping.Getting values back
To return server-generated or defaulted columns from an insert, chain.returning(...) and use
get_result/get_results instead of execute:
Handling conflicts
To make an insert idempotent or merge on a key collision, add.on_conflict(...). See
Upsert (ON CONFLICT).
See also
RETURNING
Read columns back from a write.
Upsert
ON CONFLICT DO NOTHING / DO UPDATE.Transactions
Group many writes atomically.
Appender (core)
The fast path for bulk inserts.