sqlite_dashboard 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 869bae55994f425455d02e3798d598d4d346a4d6bfa90f11898e0b4a1c36320f
4
- data.tar.gz: 030f4f2c91332a9ef73e65eb5a06be94f38c7063c65cf17b538680b1c72b155f
3
+ metadata.gz: b4be508c9964d5d3bc9e646bc297639297b468a52a3c38e9bae24d91579c63c0
4
+ data.tar.gz: 403c530bbcaacfc2d7eca3181a32386971d5b1bf5bd7348ce8e7e70668cc08c6
5
5
  SHA512:
6
- metadata.gz: a067bb74a549a6a34c9779ec167a7670c47505b76af208dfd7e2be02564d68bb9e0edda43ddab7c1b16e9ac43d13080d1f62045fee71d1cf1667fa79f00fd382
7
- data.tar.gz: 2bfb94bd33407f7f22503934b532fa93f263f40f40ca5ae2dbb1acfcd25e2e1e6b0dc6bc2aa84448e64fa38498b4bdf5bef03b6e8938f72fc3b12ca11849383e
6
+ metadata.gz: 85079f70645f372357282f1c5c506b261b8775f8d81e6b4284568ba1a8a1f294fcf789dc8162636815a20183b66b8b0056a5747b2574d94f9eec8f816fac6464
7
+ data.tar.gz: c6b9832a41c012ab642d1981dfce35f13554fac43271336e818c1778b106452432900f48953a33a93f1802e7f0aca8f3d5919c667f5cce5b03c80ef5b1122bbf
data/README.md CHANGED
@@ -9,14 +9,18 @@ A beautiful, feature-rich SQLite database browser and query interface for Rails
9
9
 
10
10
  ## Features
11
11
 
12
- - 🎨 **Modern UI** with Bootstrap 5 and responsive design
12
+ - 🎨 **Modern UI** with dark sidebar theme and responsive design
13
13
  - 🔍 **Multiple Database Support** - Configure and switch between multiple SQLite databases
14
+ - 🗄️ **Auto-Detection** - Automatically discovers SQLite databases from `config/database.yml`
14
15
  - ✨ **SQL Syntax Highlighting** - CodeMirror editor with SQL syntax highlighting and autocomplete
15
- - 📊 **Interactive Query Results** - Paginated, sortable results with horizontal scrolling
16
+ - 📊 **Interactive Query Results** - Client-side pagination with customizable rows per page
17
+ - 💾 **Export Functionality** - Export results to CSV or JSON with custom formatting options
16
18
  - 🎯 **Quick Table Browse** - Click any table name to instantly query it
17
19
  - ⚡ **Fast & Lightweight** - No build tools required, works with Rails importmap
18
- - 🔐 **Safe for Development** - Read-only access to prevent accidental data modification
20
+ - 🔒 **Read-Only Mode** - Prevents accidental data modification (configurable)
21
+ - 🚫 **Security Controls** - DROP and ALTER operations always forbidden
19
22
  - ⌨️ **Keyboard Shortcuts** - `Ctrl/Cmd + Enter` to execute queries
23
+ - 📱 **Fully Responsive** - Works beautifully on desktop and mobile devices
20
24
 
21
25
  ## Installation
22
26
 
@@ -29,10 +33,32 @@ gem 'sqlite_dashboard'
29
33
  And then execute:
30
34
 
31
35
  ```bash
32
- $ bundle install
36
+ bundle install
33
37
  ```
34
38
 
35
- ## Configuration
39
+ ## Quick Start (Recommended)
40
+
41
+ The easiest way to install SQLite Dashboard is using the built-in generator:
42
+
43
+ ```bash
44
+ rails generate sqlite_dashboard:install
45
+ ```
46
+
47
+ This will:
48
+ - ✅ Create an initializer at `config/initializers/sqlite_dashboard.rb`
49
+ - ✅ Mount the engine in your routes at `/sqlite_dashboard`
50
+ - ✅ Auto-detect your SQLite databases
51
+ - ✅ Display helpful setup instructions
52
+
53
+ Then start your Rails server and visit:
54
+
55
+ ```
56
+ http://localhost:3000/sqlite_dashboard
57
+ ```
58
+
59
+ ## Manual Configuration
60
+
61
+ If you prefer to set up manually:
36
62
 
37
63
  ### Step 1: Mount the Engine
38
64
 
@@ -52,19 +78,23 @@ Create an initializer `config/initializers/sqlite_dashboard.rb`:
52
78
 
53
79
  ```ruby
54
80
  SqliteDashboard.configure do |config|
81
+ # Option 1: Explicitly define databases
55
82
  config.db_files = [
56
83
  {
57
84
  name: "Development",
58
- path: Rails.root.join("storage", "development.sqlite3").to_s
85
+ path: Rails.root.join("db", "development.sqlite3").to_s
59
86
  },
60
87
  {
61
88
  name: "Test",
62
- path: Rails.root.join("storage", "test.sqlite3").to_s
89
+ path: Rails.root.join("db", "test.sqlite3").to_s
63
90
  }
64
91
  ]
65
92
 
66
- # Or add databases dynamically:
67
- # config.add_database("Custom DB", "/path/to/database.sqlite3")
93
+ # Option 2: Or leave empty to auto-detect from database.yml
94
+ # (Automatically loads SQLite databases for current environment)
95
+
96
+ # Security: Control write operations (default: false)
97
+ config.allow_dml = false # Read-only mode
68
98
  end
69
99
  ```
70
100
 
@@ -95,6 +125,21 @@ http://localhost:3000/sqlite_dashboard
95
125
  - Adjust rows per page (10, 25, 50, 100, 500)
96
126
  - Navigate through pages with First, Previous, Next, Last buttons
97
127
  - See current position (e.g., "Showing 1 to 25 of 150 rows")
128
+ - Client-side pagination for instant navigation
129
+
130
+ ### Export Query Results
131
+
132
+ **CSV Export:**
133
+ - Choose separator: comma, semicolon, tab, or pipe
134
+ - Option to include/exclude headers as first row
135
+ - Exports all query results (not just paginated view)
136
+
137
+ **JSON Export:**
138
+ - Two format options:
139
+ - Array of objects: `[{"col1": "val1", "col2": "val2"}, ...]`
140
+ - Object with columns & rows: `{"columns": [...], "rows": [...]}`
141
+ - Pretty print option for formatted/readable JSON
142
+ - Timestamped filenames for easy organization
98
143
 
99
144
  ### Keyboard Shortcuts
100
145
 
@@ -106,7 +151,26 @@ http://localhost:3000/sqlite_dashboard
106
151
 
107
152
  ⚠️ **Warning**: This gem provides direct SQL access to your databases.
108
153
 
109
- ### Recommended Security Measures:
154
+ ### Built-in Security Features
155
+
156
+ 1. **Read-Only Mode by Default** - DML operations are disabled by default:
157
+
158
+ ```ruby
159
+ # config/initializers/sqlite_dashboard.rb
160
+ SqliteDashboard.configure do |config|
161
+ config.allow_dml = false # Default: prevents INSERT, UPDATE, DELETE, CREATE, TRUNCATE
162
+ end
163
+ ```
164
+
165
+ 2. **Always Forbidden Operations** - DROP and ALTER are always blocked, even when `allow_dml = true`:
166
+
167
+ ```ruby
168
+ # These are NEVER allowed for safety:
169
+ # - DROP TABLE/INDEX/VIEW
170
+ # - ALTER TABLE
171
+ ```
172
+
173
+ ### Recommended Security Measures
110
174
 
111
175
  1. **Development Only** - Only mount in development environment:
112
176
 
@@ -117,7 +181,7 @@ if Rails.env.development?
117
181
  end
118
182
  ```
119
183
 
120
- 2. **Authentication** - Add authentication with Devise or similar:
184
+ 2. **Authentication with Devise** - Add authentication for production use:
121
185
 
122
186
  ```ruby
123
187
  # config/routes.rb
@@ -126,25 +190,23 @@ authenticate :user, ->(user) { user.admin? } do
126
190
  end
127
191
  ```
128
192
 
129
- 3. **Basic Auth** - Quick protection with HTTP Basic Auth:
193
+ 3. **HTTP Basic Auth** - Quick protection with HTTP Basic Auth:
130
194
 
131
195
  ```ruby
132
- # config/initializers/sqlite_dashboard.rb
196
+ # config/initializers/sqlite_dashboard.rb or config/application.rb
133
197
  SqliteDashboard::Engine.middleware.use Rack::Auth::Basic do |username, password|
134
- username == ENV['DASHBOARD_USER'] && password == ENV['DASHBOARD_PASS']
198
+ ActiveSupport::SecurityUtils.secure_compare(username, ENV['DASHBOARD_USER']) &
199
+ ActiveSupport::SecurityUtils.secure_compare(password, ENV['DASHBOARD_PASS'])
135
200
  end
136
201
  ```
137
202
 
138
- 4. **Read-Only Mode** - Configure read-only database connections:
203
+ 4. **Enable DML Only When Needed** - Only allow write operations in trusted environments:
139
204
 
140
205
  ```ruby
141
- config.db_files = [
142
- {
143
- name: "Production (Read-Only)",
144
- path: Rails.root.join("db/production.sqlite3").to_s,
145
- readonly: true # Coming in v2.0
146
- }
147
- ]
206
+ SqliteDashboard.configure do |config|
207
+ # Use environment variables or Rails.env checks
208
+ config.allow_dml = Rails.env.development? || Rails.env.test?
209
+ end
148
210
  ```
149
211
 
150
212
  ## Customization
@@ -329,13 +391,24 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/yourus
329
391
 
330
392
  ## Roadmap
331
393
 
332
- - [x] **v1.1** - Export results to CSV/JSON
333
- - [ ] **v1.2** - Query history and saved queries
334
- - [ ] **v1.3** - Database schema visualization
335
- - [ ] **v2.0** - Read-only mode enforcement
336
- - [ ] **v2.1** - Dark mode theme
337
- - [ ] **v2.2** - Multi-query execution
338
- - [ ] **v2.3** - Query performance analytics
394
+ ### Completed
395
+ - [x] **v1.0** - Core SQLite browser with modern UI
396
+ - [x] **v1.0** - SQL syntax highlighting with CodeMirror
397
+ - [x] **v1.0** - Client-side pagination
398
+ - [x] **v1.0** - Auto-detection from database.yml
399
+ - [x] **v1.0** - CSV & JSON export with options
400
+ - [x] **v1.0** - Read-only mode with DML controls
401
+ - [x] **v1.0** - Dark sidebar theme
402
+ - [x] **v1.0** - Rails generator for easy installation
403
+
404
+ ### Planned 🚀
405
+ - [ ] **v1.1** - Query history and saved queries
406
+ - [ ] **v1.2** - Database schema visualization
407
+ - [ ] **v1.3** - Table relationships diagram
408
+ - [ ] **v1.4** - Query performance analytics
409
+ - [ ] **v2.0** - Multi-query execution
410
+ - [ ] **v2.1** - Full dark mode theme toggle
411
+ - [ ] **v2.2** - SQL query builder UI
339
412
 
340
413
  ## License
341
414
 
@@ -1,6 +1,8 @@
1
1
  ===============================================================================
2
2
 
3
- SQLite Dashboard has been installed successfully!
3
+ SQLite Dashboard has been installed successfully!
4
+
5
+ ===============================================================================
4
6
 
5
7
  Next Steps:
6
8
  -----------
@@ -8,7 +10,7 @@ Next Steps:
8
10
  1. Review the configuration in:
9
11
  config/initializers/sqlite_dashboard.rb
10
12
 
11
- 2. Update the database paths to match your SQLite files
13
+ 2. (Optional) Update database paths or use auto-detection from database.yml
12
14
 
13
15
  3. Start your Rails server:
14
16
  rails server
@@ -16,35 +18,64 @@ Next Steps:
16
18
  4. Visit the dashboard at:
17
19
  http://localhost:3000/sqlite_dashboard
18
20
 
19
- Security Warning:
20
- -----------------
21
- SQLite Dashboard provides direct SQL access to your databases.
21
+ Features:
22
+ ---------
23
+ SQL syntax highlighting with CodeMirror
24
+ 📊 Paginated query results
25
+ 🔍 Quick table browsing with sidebar navigation
26
+ 💾 Export to CSV and JSON with custom options
27
+ ⌨️ Keyboard shortcuts (Ctrl/Cmd + Enter to execute)
28
+ 🎨 Modern, responsive UI with dark sidebar theme
29
+ 🔒 Read-only mode by default (configurable)
30
+ 🗄️ Auto-detects databases from config/database.yml
31
+ ⚡ Client-side pagination for fast browsing
32
+
33
+ Security Configuration:
34
+ -----------------------
35
+ By default, SQLite Dashboard runs in READ-ONLY mode.
36
+
37
+ To enable write operations, set in the initializer:
38
+ config.allow_dml = true
22
39
 
23
- For production or shared environments, add authentication:
40
+ Note: DROP and ALTER are always forbidden for safety.
24
41
 
25
- In config/routes.rb, replace the mount line with:
42
+ Production Security:
43
+ --------------------
44
+ IMPORTANT: Add authentication before deploying to production!
45
+
46
+ Option 1 - Devise/Clearance authentication:
47
+ In config/routes.rb, replace the mount line with:
26
48
 
27
49
  authenticate :user, ->(user) { user.admin? } do
28
50
  mount SqliteDashboard::Engine => "/sqlite_dashboard"
29
51
  end
30
52
 
31
- Or use HTTP Basic Auth by adding to the initializer:
53
+ Option 2 - HTTP Basic Auth:
54
+ Add to config/application.rb or the initializer:
32
55
 
33
56
  SqliteDashboard::Engine.middleware.use Rack::Auth::Basic do |user, pass|
34
- user == ENV['DASHBOARD_USER'] && pass == ENV['DASHBOARD_PASS']
57
+ ActiveSupport::SecurityUtils.secure_compare(user, ENV['DASHBOARD_USER']) &
58
+ ActiveSupport::SecurityUtils.secure_compare(pass, ENV['DASHBOARD_PASS'])
35
59
  end
36
60
 
37
- Features:
38
- ---------
39
- SQL syntax highlighting with autocomplete
40
- 📊 Paginated query results
41
- 🔍 Quick table browsing
42
- ⌨️ Keyboard shortcuts (Ctrl/Cmd + Enter to execute)
43
- 📱 Responsive design
61
+ Export Features:
62
+ ----------------
63
+ 📄 CSV Export: Choose separator (comma, semicolon, tab, pipe)
64
+ - Optional headers row
65
+ - Exports all query results (not just paginated view)
66
+
67
+ 🔧 JSON Export: Two format options
68
+ - Array of objects: [{"col1": "val1"}, ...]
69
+ - Object with columns & rows: {"columns": [...], "rows": [...]}
70
+ - Pretty print option for readable formatting
44
71
 
45
72
  Documentation:
46
73
  --------------
47
- https://github.com/sqlite-dashboard/sqlite_dashboard
74
+ https://github.com/giovapanasiti/sqlite_dashboard
75
+
76
+ Support:
77
+ --------
78
+ Report issues: https://github.com/giovapanasiti/sqlite_dashboard/issues
48
79
 
49
80
  Enjoy exploring your SQLite databases! 🎉
50
81
 
@@ -4,6 +4,10 @@
4
4
  # Only configure databases you trust, as this provides direct SQL access.
5
5
 
6
6
  SqliteDashboard.configure do |config|
7
+ # =============================================================================
8
+ # Database Configuration
9
+ # =============================================================================
10
+
7
11
  # Array of database configurations
8
12
  # Each database should have a name and path
9
13
  config.db_files = [
@@ -18,11 +22,35 @@ SqliteDashboard.configure do |config|
18
22
  # You can also add databases dynamically:
19
23
  # config.add_database("Custom DB", "/path/to/custom.sqlite3")
20
24
 
21
- # Security Note:
25
+ # If no databases are configured, SQLite Dashboard will automatically
26
+ # detect and use SQLite databases from config/database.yml for the current environment
27
+
28
+ # =============================================================================
29
+ # Security Configuration
30
+ # =============================================================================
31
+
32
+ # Allow DML operations (INSERT, UPDATE, DELETE, CREATE, TRUNCATE)
33
+ # Default: false (read-only mode)
34
+ # Note: DROP and ALTER are always forbidden for safety
35
+ config.allow_dml = false
36
+
37
+ # Set to true to allow INSERT, UPDATE, DELETE, CREATE, TRUNCATE operations
38
+ # config.allow_dml = true
39
+
40
+ # =============================================================================
41
+ # Production Security Note
42
+ # =============================================================================
43
+ #
22
44
  # For production use, wrap the mount in authentication:
23
45
  #
24
46
  # In config/routes.rb:
25
47
  # authenticate :user, ->(user) { user.admin? } do
26
48
  # mount SqliteDashboard::Engine => "/sqlite_dashboard"
27
49
  # end
50
+ #
51
+ # Or use HTTP Basic Auth (add to config/application.rb or an initializer):
52
+ # SqliteDashboard::Engine.middleware.use Rack::Auth::Basic do |user, pass|
53
+ # ActiveSupport::SecurityUtils.secure_compare(user, ENV['DASHBOARD_USER']) &
54
+ # ActiveSupport::SecurityUtils.secure_compare(pass, ENV['DASHBOARD_PASS'])
55
+ # end
28
56
  end
@@ -1,3 +1,3 @@
1
1
  module SqliteDashboard
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sqlite_dashboard
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - SQLite Dashboard Contributors
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2025-10-02 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: rails
@@ -181,7 +180,6 @@ metadata:
181
180
  wiki_uri: https://github.com/giovapanasiti/sqlite_dashboard/wiki
182
181
  funding_uri: https://github.com/sponsors/sqlite-dashboard
183
182
  rubygems_mfa_required: 'true'
184
- post_install_message:
185
183
  rdoc_options: []
186
184
  require_paths:
187
185
  - lib
@@ -196,8 +194,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
196
194
  - !ruby/object:Gem::Version
197
195
  version: '0'
198
196
  requirements: []
199
- rubygems_version: 3.5.9
200
- signing_key:
197
+ rubygems_version: 3.6.9
201
198
  specification_version: 4
202
199
  summary: Beautiful SQLite database browser and query interface for Rails
203
200
  test_files: []