class Sequel::SQLite::Dataset

  1. lib/sequel/adapters/sqlite.rb
Parent: SQLite

Dataset class for SQLite datasets that use the ruby-sqlite3 driver.

Methods

Public Instance

  1. call
  2. fetch_rows
  3. prepare

Constants

DatasetClass = self  
PREPARED_ARG_PLACEHOLDER = ':'.freeze  

Public Instance methods

call (type, bind_vars={}, *values, &block)

Execute the given type of statement with the hash of values.

[show source]
# File lib/sequel/adapters/sqlite.rb, line 348
def call(type, bind_vars={}, *values, &block)
  ps = to_prepared_statement(type, values)
  ps.extend(BindArgumentMethods)
  ps.call(bind_vars, &block)
end
fetch_rows (sql)

Yield a hash for each row in the dataset.

[show source]
# File lib/sequel/adapters/sqlite.rb, line 355
def fetch_rows(sql)
  execute(sql) do |result|
    i = -1
    cps = db.conversion_procs
    type_procs = result.types.map{|t| cps[base_type_name(t)]}
    cols = result.columns.map{|c| i+=1; [output_identifier(c), i, type_procs[i]]}
    @columns = cols.map{|c| c.first}
    result.each do |values|
      row = {}
      cols.each do |name,id,type_proc|
        v = values[id]
        if type_proc && v
          v = type_proc.call(v)
        end
        row[name] = v
      end
      yield row
    end
  end
end
prepare (type, name=nil, *values)

Prepare the given type of query with the given name and store it in the database. Note that a new native prepared statement is created on each call to this prepared statement.

[show source]
# File lib/sequel/adapters/sqlite.rb, line 379
def prepare(type, name=nil, *values)
  ps = to_prepared_statement(type, values)
  ps.extend(PreparedStatementMethods)
  if name
    ps.prepared_statement_name = name
    db.set_prepared_statement(name, ps)
  end
  ps
end