Class: ADBC::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/adbc/connection.rb

Instance Method Summary collapse

Instance Method Details

#query(sql) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/adbc/connection.rb', line 20

def query(sql)
  statement = Statement.new(self)
  begin
    statement.set_sql_query(sql)
    _, c_abi_array_stream, n_rows_affected = statement.execute
    begin
      reader = Arrow::RecordBatchReader.import(c_abi_array_stream)
      if block_given?
        yield(reader, n_rows_affected)
      else
        reader.read_all
      end
    ensure
      GLib.free(c_abi_array_stream)
    end
  ensure
    statement.release
  end
end