Sha256: f3d9dfcb7261f488d7d8d0bc61313557a98432e7abd0ab9cb2defebbf1294e21
Contents?: true
Size: 1.38 KB
Versions: 2
Compression:
Stored size: 1.38 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 dataset(opts = nil) OpenBase::Dataset.new(self, opts) end def execute(sql, opts={}) log_info(sql) synchronize(opts[:server]) do |conn| r = conn.execute(sql) yield(r) if block_given? r end end alias_method :do, :execute private def disconnect_connection(c) c.disconnect end end class Dataset < Sequel::Dataset def literal(v) case v when Time literal(v.iso8601) when Date, DateTime literal(v.to_s) else super end end 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
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
colincasey-sequel-2.10.1 | lib/sequel_core/adapters/openbase.rb |
sequel-2.10.0 | lib/sequel_core/adapters/openbase.rb |