class Sequel::SQLite::Dataset

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

Constants

BindArgumentMethods
PREPARED_ARG_PLACEHOLDER
PreparedStatementMethods

Public Instance Methods

fetch_rows(sql) { |row| ... } click to toggle source

Yield a hash for each row in the dataset.

# File lib/sequel/adapters/sqlite.rb, line 327
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]]}
    self.columns = cols.map(&: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

Private Instance Methods

base_type_name(t) click to toggle source

The base type name for a given type, without any parenthetical part.

# File lib/sequel/adapters/sqlite.rb, line 351
def base_type_name(t)
  (t =~ /^(.*?)\(/ ? $1 : t).downcase if t
end
bound_variable_modules() click to toggle source
# File lib/sequel/adapters/sqlite.rb, line 360
def bound_variable_modules
  [BindArgumentMethods]
end
literal_string_append(sql, v) click to toggle source

Quote the string using the adapter class method.

# File lib/sequel/adapters/sqlite.rb, line 356
def literal_string_append(sql, v)
  sql << "'" << ::SQLite3::Database.quote(v) << "'"
end
prepared_arg_placeholder() click to toggle source

SQLite uses a : before the name of the argument as a placeholder.

# File lib/sequel/adapters/sqlite.rb, line 369
def prepared_arg_placeholder
  PREPARED_ARG_PLACEHOLDER
end
prepared_statement_modules() click to toggle source
# File lib/sequel/adapters/sqlite.rb, line 364
def prepared_statement_modules
  [PreparedStatementMethods]
end