Standard Appender
The standard appender is a lower-level API that uses CreateCreateRow and AppendValue methods.
Use this approach for maximum performance when type safety is not needed, or when you need fine-grained control over the insertion process.
Caution
When using the standard appender, data types MUST match the length of the database types exactly. For example when inserting into a UBIGINTEGER column, a ulong such as 0UL must be used. Writing just 0 will cause data corruption by writing adjacent memory to the database.
Example
using var connection = new DuckDBConnection("DataSource=:memory:");
connection.Open();
using (var duckDbCommand = connection.CreateCommand())
{
var table = "CREATE TABLE AppenderTest(foo INTEGER, bar INTEGER);";
duckDbCommand.CommandText = table;
duckDbCommand.ExecuteNonQuery();
}
var rows = 100;
using (var appender = connection.CreateAppender("AppenderTest"))
{
for (var i = 0; i < rows; i++)
{
var row = appender.CreateRow();
row.AppendValue(i).AppendValue(i+2).EndRow();
}
}
Data Importing from Files
For importing data from CSV, Parquet, JSON and other file types see the DuckDB documentation for Data Importing.