Sha256: c72b273632edff5cf1ad390b3df90645293892998fad61556b5c58b7232423d6

Contents?: true

Size: 716 Bytes

Versions: 43

Compression:

Stored size: 716 Bytes

Contents

require 'mysql'

class Mysql
  def summary
    self.list_tables.each do |tbl|
      next if tbl =~ /^tws/
      puts "+" * 160
      puts "%80s" % tbl
      puts "+" * 160
      columns = self.query("select * from #{tbl}").fetch_hash.keys
      columns.in_chunks_of(6).each do |chunk|
        puts "%-25s " * chunk.size % chunk
      end
      puts "\n\n"
    end
  end
end



class Array
  def chunks(number_of_chunks)
    chunks_of( (self.size/number_of_chunks.to_f).ceil )
  end
  def in_chunks_of(chunk_size)
    nchunks = (self.size/chunk_size.to_f).ceil
    chunks = Array.new(nchunks) { [] }
    self.each_with_index do |item,index|
      chunks[ index/chunk_size ] << item
    end
    return chunks
  end
end

Version data entries

43 entries across 43 versions & 3 rubygems

Version Path
brainmap-ImageData-0.1.0 lib/mysql_tools.rb
brainmap-ImageData-0.1.1 lib/mysql_tools.rb
brainmap-metamri-0.1.1 lib/mysql_tools.rb
brainmap-metamri-0.1.2 lib/mysql_tools.rb
brainmap-metamri-0.1.3 lib/mysql_tools.rb
metamri-0.2.17 lib/metamri/mysql_tools.rb
metamri-0.2.16 lib/metamri/mysql_tools.rb
metamri-0.2.15 lib/metamri/mysql_tools.rb
metamri-0.2.14 lib/metamri/mysql_tools.rb
metamri-0.2.13 lib/metamri/mysql_tools.rb
metamri-0.2.12 lib/metamri/mysql_tools.rb
metamri-0.2.11 lib/metamri/mysql_tools.rb
metamri-0.2.10 lib/metamri/mysql_tools.rb
metamri-0.2.9 lib/metamri/mysql_tools.rb
metamri-0.2.8 lib/metamri/mysql_tools.rb
metamri-0.2.7 lib/metamri/mysql_tools.rb
metamri-0.2.6 lib/metamri/mysql_tools.rb
metamri-0.2.5 lib/metamri/mysql_tools.rb
metamri-0.2.4 lib/metamri/mysql_tools.rb
metamri-0.2.3 lib/metamri/mysql_tools.rb