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

Included Modules

::Sequel::SQLite::DatabaseMethods

Public Instance methods

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 78
78:       def connect(server)
79:         opts = server_opts(server)
80:         opts[:database] = ':memory:' if blank_object?(opts[:database])
81:         db = ::Amalgalite::Database.new(opts[:database])
82:         db.busy_handler(::Amalgalite::BusyTimeout.new(opts.fetch(:timeout, 5000)/50, 50))
83:         db.type_map = SequelTypeMap.new(self)
84:         connection_pragmas.each{|s| log_connection_yield(s, db){db.execute_batch(s)}}
85:         db
86:       end

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

[Source]

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

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

[Source]

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

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

[Source]

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

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

[Source]

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

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

[Source]

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

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 121
121:       def single_value(sql, opts=OPTS)
122:         _execute(sql, opts){|conn| log_connection_yield(sql, conn){conn.first_value_from(sql)}}
123:       end

[Validate]