Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Appender document #831

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions ext/duckdb/appender.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,23 @@ static VALUE appender_initialize(VALUE self, VALUE con, VALUE schema, VALUE tabl
return self;
}

/* call-seq:
* appender.begin_row -> self
*
* Begins a new row in the appender. This must be called before appending any values to the row.
*
* require 'duckdb'
* db = DuckDB::Database.open
* con = db.connect
* con.query('CREATE TABLE users (id INTEGER, name VARCHAR)')
* appender = con.appender('users')
* appender
* .begin_row
* .append_int32(1)
* .append_varchar('Alice')
* .end_row
* .flush
*/
static VALUE appender_begin_row(VALUE self) {
rubyDuckDBAppender *ctx;
TypedData_Get_Struct(self, rubyDuckDBAppender, &appender_data_type, ctx);
Expand All @@ -92,6 +109,23 @@ static VALUE appender_begin_row(VALUE self) {
return self;
}

/* call-seq:
* appender.begin_row -> self
*
* Ends a row in the appender. This must be called before starting new row.
*
* require 'duckdb'
* db = DuckDB::Database.open
* con = db.connect
* con.query('CREATE TABLE users (id INTEGER, name VARCHAR)')
* appender = con.appender('users')
* appender
* .begin_row
* .append_int32(1)
* .append_varchar('Alice')
* .end_row
* .flush
*/
static VALUE appender_end_row(VALUE self) {
rubyDuckDBAppender *ctx;
TypedData_Get_Struct(self, rubyDuckDBAppender, &appender_data_type, ctx);
Expand Down