Sha256: 6b92d1e9770e56b19d9544e7f2231d3b6d985b6e2cfc39a69b951430ccf78b62
Contents?: true
Size: 675 Bytes
Versions: 1
Compression:
Stored size: 675 Bytes
Contents
module Populator module Adapters module Sqlite # Executes multiple SQL statements in one query when joined with ";" def execute_batch(sql, name = nil) catch_schema_changes { log(sql, name) { @connection.execute_batch(sql) } } end def populate(table, columns, rows, name = nil) queries = [] rows.each do |row| queries << "INSERT INTO #{table} #{columns} VALUES #{row}" end execute_batch(queries.join(';'), name) end end end end class ActiveRecord::ConnectionAdapters::SQLiteAdapter < ActiveRecord::ConnectionAdapters::AbstractAdapter include Populator::Adapters::Sqlite end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ryanb-populator-0.1.0 | lib/populator/adapters/sqlite.rb |