class Sequel::Amalgalite::Database

  1. lib/sequel/adapters/amalgalite.rb
Superclass: Sequel::Database

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).

[show source]
   # File lib/sequel/adapters/amalgalite.rb
74 def connect(server)
75   opts = server_opts(server)
76   opts[:database] = ':memory:' if blank_object?(opts[:database])
77   db = ::Amalgalite::Database.new(opts[:database])
78   db.busy_handler(::Amalgalite::BusyTimeout.new(opts.fetch(:timeout, 5000)/50, 50))
79   db.type_map = SequelTypeMap.new(self)
80   connection_pragmas.each{|s| log_connection_yield(s, db){db.execute_batch(s)}}
81   db
82 end
database_type()
[show source]
   # File lib/sequel/adapters/amalgalite.rb
84 def database_type
85   :sqlite
86 end
execute(sql, opts=OPTS)
[show source]
    # File lib/sequel/adapters/amalgalite.rb
101 def execute(sql, opts=OPTS)
102   _execute(sql, opts) do |conn|
103     begin
104       yield(stmt = log_connection_yield(sql, conn){conn.prepare(sql)})
105     ensure
106       stmt.close if stmt
107     end
108   end
109 end
execute_ddl(sql, opts=OPTS)
[show source]
   # File lib/sequel/adapters/amalgalite.rb
88 def execute_ddl(sql, opts=OPTS)
89   _execute(sql, opts){|conn| log_connection_yield(sql, conn){conn.execute_batch(sql)}}
90   nil
91 end
execute_dui(sql, opts=OPTS)
[show source]
   # File lib/sequel/adapters/amalgalite.rb
93 def execute_dui(sql, opts=OPTS)
94   _execute(sql, opts){|conn| log_connection_yield(sql, conn){conn.execute_batch(sql)}; conn.row_changes}
95 end
execute_insert(sql, opts=OPTS)
[show source]
   # File lib/sequel/adapters/amalgalite.rb
97 def execute_insert(sql, opts=OPTS)
98   _execute(sql, opts){|conn| log_connection_yield(sql, conn){conn.execute_batch(sql)}; conn.last_insert_rowid}
99 end
single_value(sql, opts=OPTS)

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

[show source]
    # File lib/sequel/adapters/amalgalite.rb
112 def single_value(sql, opts=OPTS)
113   _execute(sql, opts){|conn| log_connection_yield(sql, conn){conn.first_value_from(sql)}}
114 end