Sha256: cc30539a3928584ddc0b62418fd129a96c90464cec6c0eb33db611cc83adfc5e

Contents?: true

Size: 1.06 KB

Versions: 91

Compression:

Stored size: 1.06 KB

Contents

#!/usr/bin/env ruby

require 'rubygems'
require 'amalgalite'

db_name = ARGV.shift
unless db_name 
  puts "Usage: #{File.basename($0)} dbname" 
  exit 1
end
db = Amalgalite::Database.new( db_name )
col_info = %w[ default_value declared_data_type collation_sequence_name not_null_constraint primary_key auto_increment ]
max_width = col_info.collect { |c| c.length }.sort.last

db.schema.tables.keys.sort.each do |table_name|
  puts "Table: #{table_name}"
  puts "=" * 42
  db.schema.tables[table_name].columns.each_pair do |col_name, col|
    puts "  Column : #{col.name}"
    col_info.each do |ci|
      puts "    |#{ci.rjust( max_width, "." )} : #{col.send( ci )}"
    end
    puts 
  end

  db.schema.tables[table_name].indexes.each_pair do |idx_name, index|
    puts "  Index : #{index.name}"
    puts "    |#{"sequence_number".rjust( max_width, "." )} : #{index.sequence_number}"
    puts "    |#{"is unique?".rjust( max_width, ".")} : #{index.unique?}"
    puts "    |#{"columns".rjust( max_width, ".")} : #{index.columns.collect { |c| c.name }.join(',') }"
    puts
  end
end

Version data entries

91 entries across 91 versions & 2 rubygems

Version Path
amalgalite-1.9.4-x64-mingw-ucrt examples/schema-info.rb
amalgalite-1.9.4-x86-mingw32 examples/schema-info.rb
amalgalite-1.9.4-x64-mingw32 examples/schema-info.rb
amalgalite-1.9.4 examples/schema-info.rb
amalgalite-1.9.1-x86-mingw32 examples/schema-info.rb
amalgalite-1.9.1-x64-mingw32 examples/schema-info.rb
amalgalite-1.9.1-x64-mingw-ucrt examples/schema-info.rb
amalgalite-1.9.1 examples/schema-info.rb
amalgalite-1.9.0-x64-mingw-ucrt examples/schema-info.rb
amalgalite-1.9.0-x86-mingw32 examples/schema-info.rb
amalgalite-1.9.0-x64-mingw32 examples/schema-info.rb
amalgalite-1.9.0 examples/schema-info.rb
amalgalite-1.8.0-x64-mingw-ucrt examples/schema-info.rb
amalgalite-1.8.0-x64-mingw32 examples/schema-info.rb
amalgalite-1.8.0-x86-mingw32 examples/schema-info.rb
amalgalite-1.8.0 examples/schema-info.rb
amalgalite-1.7.0-x86-mingw32 examples/schema-info.rb
amalgalite-1.7.0-x64-mingw32 examples/schema-info.rb
amalgalite-1.7.0 examples/schema-info.rb
amalgalite-1.6.3-x86-mingw32 examples/schema-info.rb