Sha256: 72c8a859e41522c7da4ae2d5292bc803bae087b291675718ac8b8b0c65c0258c

Contents?: true

Size: 489 Bytes

Versions: 2

Compression:

Stored size: 489 Bytes

Contents

module RailsDb
  class SqlImport
    include Connection

    attr_reader :time, :result

    def initialize(file)
      @file = file
    end

    def valid?
      if @file.nil?
        raise RailsDbError.new('Please select valid SQL file and continue')
      end
    end

    def import
      valid?
      @time   = Database.adapter.execute(@file.read)
      @result = Result.ok
    rescue RailsDbError, ActiveRecord::StatementInvalid => e
      @result = Result.new(e)
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rails_db-2.4.4 lib/rails_db/sql_import.rb
rails_db-2.4.3 lib/rails_db/sql_import.rb