Class: Sequel::SQLite::Dataset

Class | Sequel::SQLite::Dataset
In: | lib/sequel_core/adapters/sqlite.rb
Parent: | Sequel::Dataset

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

### Methods

call explain fetch_rows literal prepare

### Included Modules

::Sequel::SQLite::DatasetMethods

### Classes and Modules

Module Sequel::SQLite::Dataset::ArgumentMapper
Module Sequel::SQLite::Dataset::PreparedStatementMethods

### Constants

EXPLAIN | = | 'EXPLAIN %s'.freeze
PREPARED_ARG_PLACEHOLDER | = | ':'.freeze

### Public Instance methods

call(type, hash, values=nil, &block)

Prepare an unnamed statement of the given type and call it with the given values.

[Source]

         # File lib/sequel_core/adapters/sqlite.rb, line 189
    189:       def call(type, hash, values=nil, &block)
    190:         prepare(type, nil, values).call(hash, &block)
    191:       end

explain()

Return an array of strings specifying a query explanation for the current dataset.

[Source]

         # File lib/sequel_core/adapters/sqlite.rb, line 195
    195:       def explain
    196:         res = []
    197:         @db.result_set(EXPLAIN % select_sql(opts), nil) {|r| res << r}
    198:         res
    199:       end

fetch_rows(sql) {|row| ...}

Yield a hash for each row in the dataset.

[Source]

         # File lib/sequel_core/adapters/sqlite.rb, line 202
    202:       def fetch_rows(sql)
    203:         execute(sql) do |result|
    204:           @columns = result.columns.map{|c| output_identifier(c)}
    205:           column_count = @columns.size
    206:           result.each do |values|
    207:             row = {}
    208:             column_count.times {|i| row[@columns[i]] = values[i]}
    209:             yield row
    210:           end
    211:         end
    212:       end

literal(v)

Use the ISO format for dates and timestamps, and quote strings using the ::SQLite3::Database.quote method.

[Source]

         # File lib/sequel_core/adapters/sqlite.rb, line 216
    216:       def literal(v)
    217:         case v
    218:         when LiteralString
    219:           v
    220:         when String
    221:           "'#{::SQLite3::Database.quote(v)}'"
    222:         when Time
    223:           literal(v.iso8601)
    224:         when Date, DateTime
    225:           literal(v.to_s)
    226:         else
    227:           super
    228:         end
    229:       end

prepare(type, name=nil, values=nil)

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.

[Source]

         # File lib/sequel_core/adapters/sqlite.rb, line 234
    234:       def prepare(type, name=nil, values=nil)
    235:         ps = to_prepared_statement(type, values)
    236:         ps.extend(PreparedStatementMethods)
    237:         db.prepared_statements[name] = ps if name
    238:         ps
    239:       end

[Validate]