Class: DuckDB::Column
- Inherits:
-
Object
- Object
- DuckDB::Column
- Defined in:
- lib/duckdb/column.rb,
ext/duckdb/column.c
Instance Method Summary collapse
-
#name ⇒ Object
Returns the column name.
-
#type ⇒ Object
returns column type symbol ‘:unknown` means that the column type is unknown/unsupported by ruby-duckdb.
Instance Method Details
#name ⇒ Object
Returns the column name.
57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'ext/duckdb/column.c', line 57
VALUE duckdb_column_get_name(VALUE oDuckDBColumn) {
rubyDuckDBColumn *ctx;
VALUE result;
rubyDuckDBResult *ctxresult;
TypedData_Get_Struct(oDuckDBColumn, rubyDuckDBColumn, &column_data_type, ctx);
result = rb_ivar_get(oDuckDBColumn, rb_intern("result"));
ctxresult = get_struct_result(result);
return rb_utf8_str_new_cstr(duckdb_column_name(&(ctxresult->result), ctx->col));
}
|
#type ⇒ Object
returns column type symbol ‘:unknown` means that the column type is unknown/unsupported by ruby-duckdb. `:invalid` means that the column type is invalid in duckdb.
require 'duckdb'
db = DuckDB::Database.open
con = db.connect
con.query('CREATE TABLE users (id INTEGER, name VARCHAR(30))')
users = con.query('SELECT * FROM users')
columns = users.columns
columns.first.type #=> :integer
19 20 21 22 |
# File 'lib/duckdb/column.rb', line 19 def type type_id = _type DuckDB::Converter::IntToSym.type_to_sym(type_id) end |