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

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 74
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

[Source]

    # File lib/sequel/adapters/amalgalite.rb, line 84
84:       def database_type
85:         :sqlite
86:       end

[Source]

     # File lib/sequel/adapters/amalgalite.rb, line 101
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

[Source]

    # File lib/sequel/adapters/amalgalite.rb, line 88
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

[Source]

    # File lib/sequel/adapters/amalgalite.rb, line 93
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

[Source]

    # File lib/sequel/adapters/amalgalite.rb, line 97
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

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

[Validate]