The Swift adapter class being used by this database. Connections in this database's connection pool will be instances of this class.
Call the DATABASE_SETUP proc directly after initialization, so the object always uses sub adapter specific code. Also, raise an error immediately if the connection doesn't have a db_type specified, since one is required to include the correct subadapter.
# File lib/sequel/adapters/swift.rb, line 48 def initialize(opts) super if db_type = opts[:db_type] and !db_type.to_s.empty? if prok = DATABASE_SETUP[db_type.to_s.to_sym] prok.call(self) else raise(Error, "No :db_type option specified") end else raise(Error, ":db_type option not valid, should be postgres, mysql, or sqlite") end end
Create an instance of #swift_class for the given options.
# File lib/sequel/adapters/swift.rb, line 62 def connect(server) setup_connection(swift_class.new(server_opts(server))) end
Execute the given SQL, yielding a Swift::Result if a block is given.
# File lib/sequel/adapters/swift.rb, line 67 def execute(sql, opts={}) synchronize(opts[:server]) do |conn| begin res = log_yield(sql){conn.execute(sql)} yield res if block_given? nil rescue SwiftError => e raise_error(e) end end end
Execute the SQL on the this database, returning the number of affected rows.
# File lib/sequel/adapters/swift.rb, line 81 def execute_dui(sql, opts={}) synchronize(opts[:server]) do |conn| begin log_yield(sql){conn.execute(sql).rows} rescue SwiftError => e raise_error(e) end end end
Execute the SQL on this database, returning the primary key of the table being inserted to.
# File lib/sequel/adapters/swift.rb, line 93 def execute_insert(sql, opts={}) synchronize(opts[:server]) do |conn| begin log_yield(sql){conn.execute(sql).insert_id} rescue SwiftError => e raise_error(e) end end end