The fastest way to visualize and explore your database
DBViewer is built for developer happiness, making it effortless to explore and understand your data structure. Simple, intuitive, and enjoyable to use. Because database tools should bring joy, not frustration.
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.
Read-only operations, HTTP Basic Authentication, SQL injection protection, and query logging with audit trails.
Protect sensitive data with configurable masking rules. Automatically mask emails, phone numbers, SSNs, and custom fields while preserving data structure for development.
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
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 = 50 # 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 display
config.query_timeout = 30 # SQL query timeout in seconds
# Export Options
config.enable_data_export = false # Whether to allow data exporting
# Query Logging options (Disabled by default on Non Development Environments)
config.enable_query_logging = true
config.query_logging_mode = :file
config.query_log_path = "log/dbviewer.log"
config.max_memory_queries = 1000
# Basic Authentication (Recommended for production)
config.admin_credentials = {
username: "admin",
password: "your_secure_password"
}
# Multiple Database Support
config.database_connections = {
primary: {
connection_class: "ActiveRecord::Base",
name: "Primary Database"
},
secondary: {
connection_class: "SecondaryBaseModel",
name: "Secondary Database (Blog)"
}
}
config.current_connection = :primary
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
Experience DBViewer's full capabilities with our interactive demo featuring real sample data.
Access Live DemoDBViewer is completely open source. Explore the code, contribute to the project, or deploy it in your own applications with full documentation and examples.