/rails_db

Rails Database Viewer and SQL Query Runner

Primary LanguageRubyMIT LicenseMIT

Rails DB

Please share this gem with your friends to get more feedback. If you have ideas - please create an issue.

Build Status Gem Version

Quick way to inspect your Rails database http://localhost:3000/rails/db, see content of tables, export them to CSV, EXPLAIN SQL and run SQL queries.

Demo available on: https://rails-db.herokuapp.com/rails/db/

Video Demo: https://www.youtube.com/watch?v=ZBY9YPQdbx8

Requirements

For now was tested only with Ruby 2.2 and Rails 4.2. But expected to work with older versions too.

Main Features

  • view content of DB tables
  • sort content of DB tables
  • execute SQL queries
  • filter tables for easier navigation
  • use history of you SQL queries
  • see EXPLAIN results for your queries
  • export data to CSV
  • import SQL files
  • expand/collapse sidebar
  • added HTTP_BASIC auth for Rails DB
  • ability to turn on/off using initializer
  • white/black list of tables
  • visualize SQL schema (future)
  • data-tables inside your app (future)
  • ajax-ify Rails DB (future)
  • CRUD for table records (future)

Install

Add this to the development group in your Gemfile

For all environments (be careful with production environment):

  gem 'rails_db'

Or only for development:

  group :development do
    gem 'rails_db'
  end

Run bundle install

Visit http://localhost:3000/rails/db and you will see your database tables and SQL editors.

Customization

If you want to customize gem run in console:

rails g rails_db initializer

If will create file config/initializers/rails_db.rb.

Options

  • enabled - enable of disable gem (by default this gem is enabled only in development mode).
  • http_basic_authentication_enabled - Enable HTTP_BASIC authentication.
  • http_basic_authentication_user_name - HTTP_BASIC authentication user name.
  • http_basic_authentication_password - HTTP_BASIC authentication password.
  • black_list_tables - black list for tables (hide tables from sidebar).
  • white_list_tables - black list for tables (show only these tables in sidebar).

Samples

Schema

SQL Editor

Install & visit http://localhost:3000/rails/db to see it in action.

Contributing

  • Fork it
  • Create your feature branch (git checkout -b my-new-feature)
  • Commit your changes (git commit -am 'Added some feature')
  • Push to the branch (git push origin my-new-feature)
  • Create new Pull Request

Plans

  • add specs
  • verify all environments
  • add DB schema visualization
  • add import

License

This project uses MIT-LICENSE.