class Sequel::DataObjects::Database

  1. lib/sequel/adapters/do.rb
Parent: DataObjects

DataObjects uses it's own internal connection pooling in addition to the pooling that Sequel uses. You should make sure that you don't set the connection pool size to more than 8 for a Sequel::DataObjects::Database object, or hack DataObjects (or Extlib) to use a pool size at least as large as the pool size being used by Sequel.

Constants

DISCONNECT_ERROR_RE = /terminating connection due to administrator command/  

Public Instance methods

connect (server)

Setup a DataObjects::Connection to the database.

[show source]
# File lib/sequel/adapters/do.rb, line 48
def connect(server)
  setup_connection(::DataObjects::Connection.new(uri(server_opts(server))))
end
disconnect_connection (conn)
[show source]
# File lib/sequel/adapters/do.rb, line 52
def disconnect_connection(conn)
  conn.dispose
end
execute (sql, opts=OPTS)

Execute the given SQL. If a block is given, the DataObjects::Reader created is yielded to it. A block should not be provided unless a a SELECT statement is being used (or something else that returns rows). Otherwise, the return value is the insert id if opts is :insert, or the number of affected rows, otherwise.

[show source]
# File lib/sequel/adapters/do.rb, line 61
def execute(sql, opts=OPTS)
  synchronize(opts[:server]) do |conn|
    begin
      command = conn.create_command(sql)
      res = log_yield(sql){block_given? ? command.execute_reader : command.execute_non_query}
    rescue ::DataObjects::Error => e
      raise_error(e)
    end
    if block_given?
      begin
        yield(res)
      ensure
       res.close if res
      end
    elsif opts[:type] == :insert
      res.insert_id
    else
      res.affected_rows
    end
  end
end
execute_dui (sql, opts=OPTS)

Execute the SQL on the this database, returning the number of affected rows.

[show source]
# File lib/sequel/adapters/do.rb, line 85
def execute_dui(sql, opts=OPTS)
  execute(sql, opts)
end
execute_insert (sql, opts=OPTS)

Execute the SQL on this database, returning the primary key of the table being inserted to.

[show source]
# File lib/sequel/adapters/do.rb, line 91
def execute_insert(sql, opts=OPTS)
  execute(sql, opts.merge(:type=>:insert))
end
subadapter ()

Return the subadapter type for this database, i.e. sqlite3 for do:sqlite3::memory:.

[show source]
# File lib/sequel/adapters/do.rb, line 97
def subadapter
  uri.split(":").first
end
uri (opts=OPTS)

Return the DataObjects URI for the Sequel URI, removing the do: prefix.

[show source]
# File lib/sequel/adapters/do.rb, line 103
def uri(opts=OPTS)
  opts = @opts.merge(opts)
  (opts[:uri] || opts[:url]).sub(/\Ado:/, '')
end