Class: ADBC::Connection
- Inherits:
-
Object
- Object
- ADBC::Connection
- Defined in:
- lib/adbc/connection.rb
Instance Method Summary collapse
- #info(codes = nil) ⇒ Object
- #ingest(table_name, values, mode: :create) ⇒ Object
- #open_statement(&block) ⇒ Object
- #query(sql, &block) ⇒ Object
Instance Method Details
#info(codes = nil) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/adbc/connection.rb', line 36 def info(codes=nil) unless codes.nil? codes = codes.collect do |code| ADBC::Info.try_convert(code) end end c_abi_array_stream = get_info(codes) begin reader = Arrow::RecordBatchReader.import(c_abi_array_stream) begin table = reader.read_all values = {} table.raw_records.each do |code, value| value = value.values[0] if value.is_a?(Hash) code = ADBC::Info.try_convert(code) values[code.nick.gsub("-", "_").to_sym] = value end values ensure reader.unref end ensure GLib.free(c_abi_array_stream) end end |
#ingest(table_name, values, mode: :create) ⇒ Object
30 31 32 33 34 |
# File 'lib/adbc/connection.rb', line 30 def ingest(table_name, values, mode: :create) open_statment do |statement| statement.ingest(table_name, values, mode: mode) end end |
#open_statement(&block) ⇒ Object
20 21 22 |
# File 'lib/adbc/connection.rb', line 20 def open_statement(&block) Statement.open(self, &block) end |
#query(sql, &block) ⇒ Object
24 25 26 27 28 |
# File 'lib/adbc/connection.rb', line 24 def query(sql, &block) open_statement do |statement| statement.query(sql, &block) end end |