Skip to content

Inspect DB structure of PostgreSQL/MySQL and others

License

Notifications You must be signed in to change notification settings

tanmer/db_inspector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DbInspector

数据库结构审查工具,可获取以下数据:

  • database
  • schema
  • table
  • column

Usage

config = {
  :adapter=>"postgresql",
  :username=>"postgres",
  :port=>5432,
  :database=>"postgres",
  :host=>"localhost"
}
conn = DbInspector::Connection.establish_connection(config)
# => PostgreSQL: ({:adapter=>"postgresql", :username=>"postgres", :port=>5432, :database=>"postgres", :host=>"localhost"})
conn.databases
# => [Database: (postgres, Unconnected)]
db = conn.databases.last
# => Database: (postgres, Unconnected)
db.connect! config
# => Database: (postgres, PostgreSQL: ({:adapter=>"postgresql", :username=>"postgres", :port=>5432, :database=>"postgres", :host=>"localhost"}))
db.schemas
# => [#<DbInspector::Schema:0x00007fe59a6d0128 @database_name="postgres", @name="public", @owner="postgres">]
db.tables(schema_name: 'public')
=> [#<DbInspector::Table:0x00007fe59badc270 @database_name="postgres", @name="t1", @owner="postgres", @schema_name="public">]

Installation

Add this line to your application's Gemfile:

gem 'db_inspector'

And then execute:

$ bundle

Or install it yourself as:

$ gem install db_inspector

Contributing

Contribution directions go here.

License

The gem is available as open source under the terms of the MIT License.

About

Inspect DB structure of PostgreSQL/MySQL and others

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages