Class: Drudgery::Loaders::SQLite3Loader
- Inherits:
-
Object
- Object
- Drudgery::Loaders::SQLite3Loader
- Defined in:
- lib/drudgery/loaders/sqlite3_loader.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(db, table) ⇒ SQLite3Loader
constructor
A new instance of SQLite3Loader.
- #load(records) ⇒ Object
Constructor Details
#initialize(db, table) ⇒ SQLite3Loader
Returns a new instance of SQLite3Loader.
6 7 8 9 10 11 12 13 14 |
# File 'lib/drudgery/loaders/sqlite3_loader.rb', line 6 def initialize(db, table) @db = db @db.results_as_hash = true @db.type_translation = true @table = table @name = "sqlite3:#{main_db_name}.#{@table}" end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/drudgery/loaders/sqlite3_loader.rb', line 4 def name @name end |
Instance Method Details
#load(records) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/drudgery/loaders/sqlite3_loader.rb', line 16 def load(records) columns = records.first.keys @db.transaction do |db| records.each do |record| db.execute(sql(columns), columns.map { |column| record[column] }) end end end |