Sha256: 052152a580b6fce39f451168841894e8cb79bceaedfa6742e2d06d4f2ced2b94

Contents?: true

Size: 1.22 KB

Versions: 13

Compression:

Stored size: 1.22 KB

Contents

require 'openbase'

module Sequel
  module OpenBase
    class Database < Sequel::Database
      set_adapter_scheme :openbase
      
      def connect(server)
        opts = server_opts(server)
        OpenBase.new(
          opts[:database],
          opts[:host] || 'localhost',
          opts[:user],
          opts[:password]
        )
      end

      def disconnect_connection(c)
        c.disconnect
      end
      
      def execute(sql, opts=OPTS)
        synchronize(opts[:server]) do |conn|
          r = log_yield(sql){conn.execute(sql)}
          yield(r) if block_given?
          r
        end
      end
    end
    
    class Dataset < Sequel::Dataset
      def_sql_method(self, :select, %w'select distinct columns from join where group having compounds order limit')

      Database::DatasetClass = self
      
      def fetch_rows(sql)
        execute(sql) do |result|
          begin
            @columns = result.column_infos.map{|c| output_identifier(c.name)}
            result.each do |r|
              row = {}
              r.each_with_index {|v, i| row[@columns[i]] = v}
              yield row
            end
          ensure
            # result.close
          end
        end
        self
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
sequel-4.21.0 lib/sequel/adapters/openbase.rb
sequel-4.20.0 lib/sequel/adapters/openbase.rb
sequel-4.19.0 lib/sequel/adapters/openbase.rb
sequel-4.18.0 lib/sequel/adapters/openbase.rb
sequel-4.17.0 lib/sequel/adapters/openbase.rb
sequel-4.16.0 lib/sequel/adapters/openbase.rb
asana2flowdock-1.0.0 vendor/bundle/ruby/1.9.1/gems/sequel-4.15.0/lib/sequel/adapters/openbase.rb
sequel-4.15.0 lib/sequel/adapters/openbase.rb
sequel-4.14.0 lib/sequel/adapters/openbase.rb
sequel-4.13.0 lib/sequel/adapters/openbase.rb
sequel-4.12.0 lib/sequel/adapters/openbase.rb
sequel-4.11.0 lib/sequel/adapters/openbase.rb
sequel-4.10.0 lib/sequel/adapters/openbase.rb