The fastest way to visualize and explore your database
DBViewer is a powerful Rails engine that provides a comprehensive interface to view, explore, and manage database tables, records, and schema. It's designed for development, debugging, and database analysis, offering a clean and intuitive way to interact with your application's database.
Comprehensive overview with database statistics, analytics, and quick access to all tables and relationships.
Write and execute SQL queries with syntax highlighting, auto-completion, and paginated results display.
Navigate your database schema visually. Explore tables, columns, relationships, and indexes without writing SQL.
Interactive ERD visualization showing table relationships, foreign keys, and database structure at a glance.
Full CRUD operations (Create, Read, Update, Delete) for database records with intuitive interfaces and validation.
Table and column-level access restrictions, authentication, and configurable security features for production safety.
Protect sensitive data with configurable masking rules. Automatically mask emails, phone numbers, SSNs, and custom fields while preserving data structure.
Connect to multiple databases simultaneously, switch between connections, and manage different database environments.
Get DBViewer up and running in your Rails application in just a few steps.
Add DBViewer to your application's Gemfile:
gem "dbviewer"
Run bundle to install the gem:
bundle install
Add the engine to your routes file:
Rails.application.routes.draw do
# Your application routes...
# Mount the DBViewer engine
mount Dbviewer::Engine, at: "/dbviewer"
end
Generate configuration file for customization:
rails generate dbviewer:install
For Rails API-only applications, add Flash middleware:
# config/application.rb
module YourApp
class Application < Rails::Application
# ... existing configuration
# Required for DBViewer flash messages
config.middleware.use ActionDispatch::Flash
end
end
Customize DBViewer with the generated configuration file:
# config/initializers/dbviewer.rb
Dbviewer.configure do |config|
# Datatable Pagination Settings
config.per_page_options = [10, 20, 50, 100, 250] # Default pagination options
config.default_per_page = 20 # Default records per page
# SQL Query Settings
config.max_query_length = 10000 # Maximum SQL query length
config.cache_expiry = 300 # Cache expiration in seconds
config.max_records = 10000 # Maximum records to return in any query
config.query_timeout = 30 # SQL query timeout in seconds
# Data Management Options
config.enable_data_export = false # Whether to allow data exporting
config.enable_record_deletion = true # Whether to allow record deletion
config.enable_record_editing = true # Whether to allow record editing
# Query Logging Options
config.enable_query_logging = false # Enable or disable query logging completely
config.query_logging_mode = :memory # Storage mode for SQL queries (:memory or :file)
config.query_log_path = "log/dbviewer.log" # Path for query log file when in :file mode
config.max_memory_queries = 1000 # Maximum number of queries to store in memory
# Authentication Options
# config.admin_credentials = { username: "admin", password: "your_secure_password" }
# Table and Column Access Control
# config.access_control_mode = :whitelist # :whitelist, :blacklist, or :none (default)
# config.allowed_tables = ['users', 'orders', 'products'] # Only these tables accessible
# config.blocked_tables = ['admin_users', 'sensitive_data'] # These tables blocked
# config.blocked_columns = { # Hide sensitive columns from specific tables
# 'users' => ['password_digest', 'api_key', 'secret_token'],
# 'orders' => ['internal_notes']
# }
# Multiple Database Support
config.database_connections = {
primary: {
connection_class: "ActiveRecord::Base",
name: "Primary Database"
},
secondary: {
connection_class: "SecondaryDatabase",
name: "Blog Database"
}
}
config.current_connection = :primary
# Disable DBViewer completely in production
# config.disabled = Rails.env.production?
end
Protect sensitive data with configurable masking rules:
# config/initializers/dbviewer.rb
Dbviewer.configure do |config|
config.enable_pii_masking = true # Enable PII masking (default: true)
end
# Define PII masking rules
Dbviewer.configure_pii do |pii|
# Built-in masking types
pii.mask 'users.email', with: :email # john@example.com → jo***@example.com
pii.mask 'users.phone', with: :phone # +1234567890 → +1***90
pii.mask 'users.ssn', with: :ssn # 123456789 → ***-**-6789
pii.mask 'payments.card_number', with: :credit_card # 1234567890123456 → ****-****-****-3456
pii.mask 'users.api_key', with: :full_redact # any_value → ***REDACTED***
# Custom masking with lambda
pii.mask 'users.salary', with: ->(value) { value ? '$***,***' : value }
# Define reusable custom masks
pii.custom_mask :ip_mask, ->(value) {
return value if value.nil?
parts = value.split('.')
"#{parts[0]}.#{parts[1]}.***.***.***"
}
pii.mask 'logs.ip_address', with: :ip_mask
end
Protect your database with comprehensive security features:
DBViewer provides a complete set of CRUD operations for your database records:
All data management features can be individually enabled or disabled through configuration options.
Experience DBViewer's full capabilities with our interactive demo featuring real sample data.
Visualize your database structure and access key statistics at a glance
Browse, edit, and manage database records with full CRUD operations
Explore database relationships through visual diagrams
DBViewer is completely open source. Explore the code, contribute to the project, or deploy it in your own applications with full documentation and examples.