| 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 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
Amalgalite is just the SQLite database without a separate SQLite installation.
# File lib/sequel/adapters/amalgalite.rb, line 87
87: def database_type
88: :sqlite
89: end
Run the given SQL with the given arguments and yield each row.
# 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