Class | Sequel::Amalgalite::Database
In: | lib/sequel/adapters/amalgalite.rb
Parent: | Sequel::Database

Database class for SQLite databases used with Sequel and the amalgalite driver.

### Methods

connect database_type execute execute_ddl execute_dui execute_insert single_value

### Included Modules

::Sequel::SQLite::DatabaseMethods

### Public Instance methods

connect(server)

Connect to the database. Since SQLite is a file based database, the only options available are :database (to specify the database name), and :timeout, to specify how long to wait for the database to be available if it is locked, given in milliseconds (default is 5000).

[Source]

        # File lib/sequel/adapters/amalgalite.rb, line 76
    76:       def connect(server)
    77:         opts = server_opts(server)
    78:         opts[:database] = ':memory:' if blank_object?(opts[:database])
    79:         db = ::Amalgalite::Database.new(opts[:database])
    80:         db.busy_handler(::Amalgalite::BusyTimeout.new(opts.fetch(:timeout, 5000)/50, 50))
    81:         db.type_map = SequelTypeMap.new(self)
    82:         connection_pragmas.each{|s| log_yield(s){db.execute_batch(s)}}
    83:         db
    84:       end

database_type()

Amalgalite is just the SQLite database without a separate SQLite installation.

[Source]

        # File lib/sequel/adapters/amalgalite.rb, line 87
    87:       def database_type
    88:         :sqlite
    89:       end

execute(sql, opts={}) {|stmt = log_yield(sql{conn.prepare(sql)}| ...}

Run the given SQL with the given arguments and yield each row.

[Source]

         # File lib/sequel/adapters/amalgalite.rb, line 108
    108:       def execute(sql, opts={})
    109:         _execute(sql, opts) do |conn|
    110:           begin
    111:             yield(stmt = log_yield(sql){conn.prepare(sql)})
    112:           ensure
    113:             stmt.close if stmt
    114:           end
    115:         end
    116:       end

execute_ddl(sql, opts={})

Run the given SQL with the given arguments. Returns nil.

[Source]

        # File lib/sequel/adapters/amalgalite.rb, line 92
    92:       def execute_ddl(sql, opts={})
    93:         _execute(sql, opts){|conn| log_yield(sql){conn.execute_batch(sql)}}
    94:         nil
    95:       end

execute_dui(sql, opts={})

Run the given SQL with the given arguments and return the number of changed rows.

[Source]

         # File lib/sequel/adapters/amalgalite.rb, line 98
     98:       def execute_dui(sql, opts={})
     99:         _execute(sql, opts){|conn| log_yield(sql){conn.execute_batch(sql)}; conn.row_changes}
    100:       end

execute_insert(sql, opts={})

Run the given SQL with the given arguments and return the last inserted row id.

[Source]

         # File lib/sequel/adapters/amalgalite.rb, line 103
    103:       def execute_insert(sql, opts={})
    104:         _execute(sql, opts){|conn| log_yield(sql){conn.execute_batch(sql)}; conn.last_insert_rowid}
    105:       end

single_value(sql, opts={})

Run the given SQL with the given arguments and return the first value of the first row.

[Source]

         # File lib/sequel/adapters/amalgalite.rb, line 119
    119:       def single_value(sql, opts={})
    120:         _execute(sql, opts){|conn| log_yield(sql){conn.first_value_from(sql)}}
    121:       end

[Validate]