class SQLite3::Database
def execute_batch(sql, bind_vars = [])
See also #execute_batch2 for additional ways of
This always returns the result of the last statement.
statement.
in turn. The same bind parameters, if given, will be applied to each
string, ignoring all subsequent statements. This will execute each one
means of executing queries will only execute the first statement in the
Executes all SQL statements in the given string. By contrast, the other
def execute_batch(sql, bind_vars = []) sql = sql.strip result = nil until sql.empty? prepare(sql) do |stmt| unless stmt.closed? # FIXME: this should probably use sqlite3's api for batch execution # This implementation requires stepping over the results. if bind_vars.length == stmt.bind_parameter_count stmt.bind_params(bind_vars) end result = stmt.step end sql = stmt.remainder.strip end end result end