<commit_before>require_relative 'BaseAction.rb'

module PPCurses

  class InsertSQLDataAction < GetDataAction

    def initialize( actions, sql, db )
      super(actions)
      @sql = sql
      @db = db
    end

    def winHeight()
      8 + @actions.length
    end

    def afterActions()
      preparedSql = @sql
      dataArray = []

      @actions.each do |action|
        preparedSql = preparedSql.sub('?', action.data)
        dataArray.push(action.data)
      end

      self.promptToChangeData(preparedSql, dataArray)
      
    end

    def promptToChangeData(userDisplaySQL, dataArray)
      self.printLine(userDisplaySQL)

      proceed = GetBooleanAction.new('Proceed? ')
      proceed.setParentAction(self)
      proceed.setWindow(@win)
      proceed.execute()

      if proceed.data == '1' then
        self.printLine('')
        begin
          prepStatement = db.prepare(sql)
          prepStatement.bind_params(dataArray)
          prepStatement.execute()
          prepStatement.close()
          self.printSuccessLine('Execution successful')
        rescue SQLite3::Exception => e
          self.printErrorLine('Exception occurred')
          self.printErrorLine(e.message)
        ensure
          self.printLine('')
          self.printLine('< Press any key to continue > ')
          @win.getch()
        end

      end


    end

  end

end
<commit_msg>Variable scope<commit_after>require_relative 'BaseAction.rb'

module PPCurses

  class InsertSQLDataAction < GetDataAction

    def initialize( actions, sql, db )
      super(actions)
      @sql = sql
      @db = db
    end

    def winHeight()
      8 + @actions.length
    end

    def afterActions()
      preparedSql = @sql
      dataArray = []

      @actions.each do |action|
        preparedSql = preparedSql.sub('?', action.data)
        dataArray.push(action.data)
      end

      self.promptToChangeData(preparedSql, dataArray)
      
    end

    def promptToChangeData(userDisplaySQL, dataArray)
      self.printLine(userDisplaySQL)

      proceed = GetBooleanAction.new('Proceed? ')
      proceed.setParentAction(self)
      proceed.setWindow(@win)
      proceed.execute()

      if proceed.data == '1' then
        self.printLine('')
        begin
          prepStatement = @db.prepare(@sql)
          prepStatement.bind_params(dataArray)
          prepStatement.execute()
          prepStatement.close()
          self.printSuccessLine('Execution successful')
        rescue SQLite3::Exception => e
          self.printErrorLine('Exception occurred')
          self.printErrorLine(e.message)
        ensure
          self.printLine('')
          self.printLine('< Press any key to continue > ')
          @win.getch()
        end

      end


    end

  end

end

{'fraction_non_alphanumeric': 0.09509981851179673, 'fraction_numerical': 0.002177858439201452, 'mean_word_length': 2.175115207373272, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2262675', 'n_tokens_mistral': 793, 'n_tokens_neox': 772, 'n_words': 163}