Class Sequel::DataObjects::Database
In: lib/sequel/adapters/do.rb
Parent: Sequel::Database

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.

Methods

Constants

DISCONNECT_ERROR_RE = /terminating connection due to administrator command/

Public Instance methods

Setup a DataObjects::Connection to the database.

[Source]

    # File lib/sequel/adapters/do.rb, line 36
36:       def connect(server)
37:         setup_connection(::DataObjects::Connection.new(uri(server_opts(server))))
38:       end

[Source]

    # File lib/sequel/adapters/do.rb, line 40
40:       def disconnect_connection(conn)
41:         conn.dispose
42:       end

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[:type] is :insert, or the number of affected rows, otherwise.

[Source]

    # File lib/sequel/adapters/do.rb, line 49
49:       def execute(sql, opts=OPTS)
50:         synchronize(opts[:server]) do |conn|
51:           begin
52:             command = conn.create_command(sql)
53:             res = log_yield(sql){block_given? ? command.execute_reader : command.execute_non_query}
54:           rescue ::DataObjects::Error => e
55:             raise_error(e)
56:           end
57:           if block_given?
58:             begin
59:               yield(res)
60:             ensure
61:              res.close if res
62:             end
63:           elsif opts[:type] == :insert
64:             res.insert_id
65:           else
66:             res.affected_rows
67:           end
68:         end
69:       end

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

[Source]

    # File lib/sequel/adapters/do.rb, line 73
73:       def execute_dui(sql, opts=OPTS)
74:         execute(sql, opts)
75:       end

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

[Source]

    # File lib/sequel/adapters/do.rb, line 79
79:       def execute_insert(sql, opts=OPTS)
80:         execute(sql, opts.merge(:type=>:insert))
81:       end

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

[Source]

    # File lib/sequel/adapters/do.rb, line 85
85:       def subadapter
86:         uri.split(":").first
87:       end

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

[Source]

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

[Validate]