| Class | Sequel::Amalgalite::Database |
| In: |
lib/sequel/adapters/amalgalite.rb
|
| Parent: | Sequel::Database |
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).
# File lib/sequel/adapters/amalgalite.rb, line 66
66: def connect(server)
67: opts = server_opts(server)
68: opts[:database] = ':memory:' if blank_object?(opts[:database])
69: db = ::Amalgalite::Database.new(opts[:database])
70: db.busy_handler(::Amalgalite::BusyTimeout.new(opts.fetch(:timeout, 5000)/50, 50))
71: db.type_map = SequelTypeMap.new
72: db
73: end
Amalgalite is just the SQLite database without a separate SQLite installation.
# File lib/sequel/adapters/amalgalite.rb, line 76
76: def database_type
77: :sqlite
78: end
Return instance of Sequel::Amalgalite::Dataset with the given options.
# File lib/sequel/adapters/amalgalite.rb, line 81
81: def dataset(opts = nil)
82: Amalgalite::Dataset.new(self, opts)
83: end
Run the given SQL with the given arguments and yield each row.
# File lib/sequel/adapters/amalgalite.rb, line 102
102: def execute(sql, opts={})
103: _execute(sql, opts) do |conn|
104: begin
105: yield(stmt = log_yield(sql){conn.prepare(sql)})
106: ensure
107: stmt.close if stmt
108: end
109: end
110: end