class Sequel::Hive::Database
Public Instance Methods
connect(server)
click to toggle source
# File lib/sequel/adapters/hive.rb, line 10 def connect(server) opts = server_opts(server) RBHive::Connection.new(opts[:host], opts[:port] || 10_000) end
dataset(opts = nil)
click to toggle source
# File lib/sequel/adapters/hive.rb, line 15 def dataset(opts = nil) Hive::Dataset.new(self, opts) end
execute(sql, opts={}) { |r| ... }
click to toggle source
# File lib/sequel/adapters/hive.rb, line 19 def execute(sql, opts={}) synchronize(opts[:server]) do |conn| conn.open r = log_yield(sql){conn.fetch(sql)} yield(r) if block_given? r end end
Also aliased as: do
schema(table, opts={})
click to toggle source
Returns the schema for the given table as an array with all members being arrays of length 2, the first member being the column name, and the second member being a hash of column information.
# File lib/sequel/adapters/hive.rb, line 34 def schema(table, opts={}) hero = execute("DESCRIBE #{table}") hero.map do |h| [ h[:col_name].to_sym, { :db_type => h[:data_type] , :comment => h[:comment] } ] end end
tables(opts={})
click to toggle source
Returns a list of tables as symbols.
# File lib/sequel/adapters/hive.rb, line 44 def tables(opts={}) execute('SHOW TABLES').map{|i| i.values}.reduce(:+).map{|i| i.to_sym} end
Private Instance Methods
disconnect_connection(c)
click to toggle source
# File lib/sequel/adapters/hive.rb, line 50 def disconnect_connection(c) c.close end