Skip to main content
Writing rows with diesel::insert_into. This is Diesel’s portable insert builder on the DuckDB backend.

Single row

Pass a tuple of column.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:
For very large bulk loads, the ORM insert path is not the fastest option. Drop to the core appender via conn.inner_mut() — it is purpose-built for high-throughput inserts.

Inserting structs

A #[derive(Insertable)] struct becomes a value set. Fields map to columns by name:
See Schema for deriving 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:
Full details on the RETURNING page.

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.