Module: DisplayOverview

Defined in:
lib/display_overview.rb

Class Method Summary collapse

Class Method Details

.show(tables) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/display_overview.rb', line 2

def self.show(tables)
  if !tables.size.zero?
    puts "You have #{tables.size} tables in your database:".green
    tables.size.times do |n|
      term = "SELECT count(id) FROM #{tables[n]}"
      begin
        res = $conn.exec(term)
      rescue StandardError => e
        res = nil



      end

      result = res ? "~> #{tables[n]} (#{res[0]['count']})".yellow : "Can not find #{tables[n]} in database".red
      puts result
    end
  end
end