class DuckDB::Config
The DuckDB::Config encapsulates DuckDB Configuration.
require 'duckdb'
config = DuckDB::Config.new
config['default_order'] = 'DESC'
db = DuckDB::Database.open(nil, config)
con = db.connect
con.query('CREATE TABLE numbers (number INTEGER)')
con.query('INSERT INTO numbers VALUES (2), (1), (4), (3)')
# number is ordered by descending.
r = con.query('SELECT number FROM numbers ORDER BY number)
r.first.first # => 4
Public Class Methods
Source
static VALUE config_s_get_config_flag(VALUE klass, VALUE value) {
const char *pkey;
const char *pdesc;
size_t i = NUM2INT(value);
if (duckdb_get_config_flag(i, &pkey, &pdesc) == DuckDBError) {
rb_raise(eDuckDBError, "failed to get config information of index %ld", i);
}
return rb_ary_new3(2, rb_utf8_str_new_cstr(pkey), rb_utf8_str_new_cstr(pdesc));
}
Also aliased as: key_description
returns available configuration name and the description. The return value is array object. The first element is the configuration name. The second is the description.
key, desc = DuckDB::Config.key_description(0) key # => "access_mode" desc # => "Access mode of the database ([AUTOMATIC], READ_ONLY or READ_WRITE)"
Alias for: get_config_flag
Source
# File lib/duckdb/config.rb, line 37 def key_descriptions @key_descriptions ||= (0...size).each_with_object({}) do |i, hash| key, description = key_description(i) hash[key] = description end end
returns the Hash object of all available configuration names and the descriptions.
configs = DuckDB::Config.key_descriptions configs # => “The order type used when none is specified ([ASC] or DESC)”
Source
static VALUE config_initialize(VALUE self) {
rubyDuckDBConfig *ctx;
TypedData_Get_Struct(self, rubyDuckDBConfig, &config_data_type, ctx);
if (duckdb_create_config(&(ctx->config)) == DuckDBError) {
rb_raise(eDuckDBError, "failed to create config");
}
return self;
}
Public Instance Methods
set configuration value
config = DuckDB::Config.new
# config.set_config('default_order', 'DESC')
config['default_order'] = 'DESC'
db = DuckDB::Database.open(nil, config)
con = db.connect
con.query('CREATE TABLE numbers (number INTEGER)')
con.query('INSERT INTO numbers VALUES (2), (1), (4), (3)')
# numbers are ordered by descending.
r = con.query('SELECT number FROM numbers ORDER BY number)
r.first.first # => 4
Alias for: set_config
Source
static VALUE config_set_config(VALUE self, VALUE key, VALUE value) {
const char *pkey = StringValuePtr(key);
const char *pval = StringValuePtr(value);
rubyDuckDBConfig *ctx;
TypedData_Get_Struct(self, rubyDuckDBConfig, &config_data_type, ctx);
if (duckdb_set_config(ctx->config, pkey, pval) == DuckDBError) {
rb_raise(eDuckDBError, "failed to set config %s => %s", pkey, pval);
}
return self;
}
Also aliased as: []=