lib/wyrm/pump.rb
# start_row is zero-based
#
# TODO don't generate the full insert, ie leave out the fields
# because we've already checked that the columns and the table
# match.
# TODO generate column names in insert, they might still work
# if columns have been added to the db, but not the dump.
start_row is zero-based
TODO don't generate the full insert, ie leave out the fields
because we've already checked that the columns and the table
match.
TODO generate column names in insert, they might still work
if columns have been added to the db, but not the dump.
start_row is zero - based TODO don ' t generate the full insert ie leave out the fields because we ' ve already checked that the columns and the table match . TODO generate column names in insert they might still work if columns have been added to the db but not the dump .
def restore( start_row: 0, filename: 'io' )
      columns = table_dataset.columns
      row_enum = each_row
      return unless dump_matches_columns?( row_enum, columns )
      logger.info "{__method__} inserting to {table_name} from {start_row}"
      logger.debug "  {columns.inspect}"
      rows_restored = 0
      if start_row != 0
        logger.debug{ "skipping {start_row} rows from {filename}" }
        start_row.times do |i|
          row_enum.next
          logger.debug{ "skipped {i} from {filename}" } if i % page_size == 0
        end
        logger.debug{ "skipped {start_row} from {filename}" }
        rows_restored += start_row
      end
      loop do
        db.transaction do
          begin
            page_size.times do
               Uses a private method so it will need to be updated repeatedly.
              sql = table_dataset.clone( columns: columns, values: row_enum.next ).send(:_insert_sql)
              db.execute sql unless dry_run?
              rows_restored += 1
            end
          rescue StopIteration
             reached the end of the inout stream.
             So commit this transaction, and then re-raise
             StopIteration to get out of the loop{} statement
            db.after_commit{ raise StopIteration }
          end
        end
      end
      logger.info "{__method__} {table_name} done. Inserted {rows_restored}."
      rows_restored
    end
def restore ( start_row : 0 , filename : 'io' ) columns = table_dataset . columns row_enum = each_row return unless dump_matches_columns? ( row_enum , columns ) logger . info "#{__method__} inserting to #{table_name} from #{start_row}" logger . debug "  #{columns.inspect}" rows_restored = 0 if start_row != 0 logger . debug { "skipping #{start_row} rows from #{filename}" } start_row . times do | i | row_enum . next logger . debug { "skipped #{i} from #{filename}" } if i % page_size == 0 end logger . debug { "skipped #{start_row} from #{filename}" } rows_restored += start_row end loop do db . transaction do begin page_size . times do sql = table_dataset . clone ( columns : columns , values : row_enum . next ) . send ( :_insert_sql ) db . execute sql unless dry_run? rows_restored += 1 end rescue StopIteration db . after_commit { raise StopIteration } end end end logger . info "#{__method__} #{table_name} done. Inserted #{rows_restored}." rows_restored end
start_row is zero-based
TODO don't generate the full insert, ie leave out the fields
because we've already checked that the columns and the table
match.
start_row is zero - based TODO don ' t generate the full insert ie leave out the fields because we ' ve already checked that the columns and the table match .
# This skips all the checks in the Sequel code. Basically we want # to generate the #   insert into (field1,field2) values (value1,value2) # statement as quickly as possible. # # Uses a private method so it will need to be updated repeatedly. # reached the end of the inout stream. # So commit this transaction, and then re-raise # StopIteration to get out of the loop{} statement
start_row
<not_specific>
filename
<not_specific>