NAME

DBD::DuckDB::Appender - Appender helper for DuckDB

use DBI;
use DBD::DuckDB::Constants qw(:duckdb_types);

my $dbh = DBI->connect("dbi:DuckDB:dbname=$dbname");

my $appender = $dbh->x_duckdb_appender('people');

$appender->append(1,            DUCKDB_TYPE_INTEGER);
$appender->append('Larry Wall', DUCKDB_TYPE_VARCHAR);
$appender->end_row;

$appender->append_row(id => 1, name => 'Larry Wall');

DESCRIPTION

Appenders are the most efficient way of loading data into DuckDB from within the C interface, and are recommended for fast data loading. The appender is much faster than using prepared statements or individual INSERT INTO statements.

METHODS

append

$appender->append($value, $type);

Append a single column.

append_row

$appender->append_row(%row_data);

Append a single row.

error

my $err = $appender->error;

Returns the error message associated with the appender. If the appender has no error message, this returns undef instead.

destroy

my $rc = $appender->destroy;

Closes the appender by flushing all intermediate states to the table and destroying it. By destroying it, this function de-allocates all memory associated with the appender. If flushing the data triggers a constraint violation, then all data is invalidated, and this function returns error.

flush

my $rc = $appender->flush;

Flush the appender to the table, forcing the cache of the appender to be cleared. If flushing the data triggers a constraint violation or any other error, then all data is invalidated, and this function returns error. It is not possible to append more values.

close

my $rc = $appender->close;

Closes the appender by flushing all intermediate states and closing it for further appends. If flushing the data triggers a constraint violation or any other error, then all data is invalidated, and this function returns error.

SUPPORT

Bugs / Feature Requests

Please report any bugs or feature requests through the issue tracker at https://github.com/giterlizzi/perl-DBD-DuckDB/issues. You will be notified automatically of any progress on your issue.

Source Code

This is open source software. The code repository is available for public review and contribution under the terms of the license.

https://github.com/giterlizzi/perl-DBD-DuckDB

git clone https://github.com/giterlizzi/perl-DBD-DuckDB.git

AUTHOR

  • Giuseppe Di Terlizzi <gdt@cpan.org>

LICENSE AND COPYRIGHT

This software is copyright (c) 2024-2025 by Giuseppe Di Terlizzi.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.