db-gui 0.0.1 → 0.0.3
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 +4 -4
- data/CHANGELOG.md +13 -0
- data/README.md +6 -17
- data/VERSION +1 -1
- data/app/db_gui/model/db_config.rb +38 -1
- data/app/db_gui/view/db_command_form.rb +25 -5
- data/app/db_gui/view/db_command_result_table.rb +30 -0
- data/app/db_gui/view/db_config_form.rb +5 -0
- data/app/db_gui/view/db_gui_application.rb +2 -3
- metadata +7 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b93f7698476d8a7a0eed435d523590e3ba887a372ef56ace685f0fbb7eb66588
|
4
|
+
data.tar.gz: c3f889910e33eeafb5b3098d63ad47448a1a96a790f12fd2ed3be9e81e7e732a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35c78168f441c66d2abdccf95a400cd3302c945dda9f95fb0848b7eaed0bb8f0f38e2a306561d7545d76e9ae0d4d622d333077f9e85eb3160839de0e77c6e738
|
7
|
+
data.tar.gz: 91dcb7804097dd4383132705da954ad74bed0ca8a9a2e9ca8d8b28f95dad1adbb63a6fa0a8bb32509b202c6bb6914aec647da8711707b08ffb5eb01e868b4e58
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,18 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 0.0.3
|
4
|
+
|
5
|
+
- Show count of rows produced by a DB command result
|
6
|
+
- Terminate DB commands (SQL statements) with a semi-colon for convenience if they did not have a semi-colon already (to avoid having them fail)
|
7
|
+
- Increase max timeout to 60*60*1000 (1 hour)
|
8
|
+
|
9
|
+
## 0.0.2
|
10
|
+
|
11
|
+
- Support displaying DB command results in a table instead of a non_wrapping_multiline_entry
|
12
|
+
- Ensure connecting to DB disables DB configuration fields
|
13
|
+
- Make DB command timeout configurable via Timeout field (in milliseconds)
|
14
|
+
- Make DB command timeout configurable via ENV var DB_COMMAND_TIMEOUT_IN_MILLISECONDS (default is 300 milliseconds)
|
15
|
+
|
3
16
|
## 0.0.1
|
4
17
|
|
5
18
|
- DB GUI for PostgreSQL database with support for running SQL queries and seeing their result as text
|
data/README.md
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
# DB GUI (Database Graphical User Interface) 0.0.
|
1
|
+
# DB GUI (Database Graphical User Interface) 0.0.3
|
2
2
|
## [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=40 /> Glimmer DSL for LibUI Application](https://github.com/AndyObtiva/glimmer-dsl-libui)
|
3
|
-
[](http://badge.fury.io/rb/db-gui)
|
4
4
|
|
5
5
|
|
6
|
-
This is
|
6
|
+
This is an early alpha database graphical user interface that enables interaction with a relational SQL database.
|
7
7
|
|
8
8
|
It currently supports PostgreSQL as a start, with the potential of supporting many other databases in the future.
|
9
9
|
|
@@ -13,7 +13,7 @@ It currently supports PostgreSQL as a start, with the potential of supporting ma
|
|
13
13
|
|
14
14
|
Run:
|
15
15
|
```
|
16
|
-
gem install db-gui -v0.0.
|
16
|
+
gem install db-gui -v0.0.3
|
17
17
|
```
|
18
18
|
|
19
19
|
## Usage
|
@@ -23,20 +23,9 @@ Run:
|
|
23
23
|
dbui
|
24
24
|
```
|
25
25
|
|
26
|
-
Or run
|
27
|
-
```
|
28
|
-
db-ui
|
29
|
-
```
|
26
|
+
Or, run one of the aliases: `db-ui` / `dbgui` / `db-gui`
|
30
27
|
|
31
|
-
|
32
|
-
```
|
33
|
-
dbgui
|
34
|
-
```
|
35
|
-
|
36
|
-
Or run alias:
|
37
|
-
```
|
38
|
-
db-gui
|
39
|
-
```
|
28
|
+
Note that it stores the last connection details under `~/.db_gui`, and will auto-connect using that configuration on startup for extra convenience (in the future, there is the potential to support multiple connection configurations).
|
40
29
|
|
41
30
|
## Change Log
|
42
31
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.3
|
@@ -10,10 +10,12 @@ class DbGui
|
|
10
10
|
alias connected? connected
|
11
11
|
attr_accessor :db_command_result
|
12
12
|
attr_accessor :db_command
|
13
|
+
attr_accessor :db_command_timeout
|
13
14
|
|
14
15
|
def initialize
|
15
16
|
self.port = 5432 # PostgreSQL default port
|
16
17
|
self.db_command_result = ''
|
18
|
+
self.db_command_timeout = (ENV['DB_COMMAND_TIMEOUT_IN_MILLISECONDS'] || 300).to_i
|
17
19
|
load_db_config
|
18
20
|
connect if to_a.none? {|value| value.nil? || (value.respond_to?(:empty?) && value.empty?) }
|
19
21
|
end
|
@@ -43,6 +45,8 @@ class DbGui
|
|
43
45
|
end
|
44
46
|
|
45
47
|
def run_io_command(command)
|
48
|
+
command = command.strip
|
49
|
+
command = "#{command};" unless command.end_with?(';')
|
46
50
|
@io_command_try ||= 0
|
47
51
|
@io_command_try += 1
|
48
52
|
io.puts(command)
|
@@ -56,6 +60,18 @@ class DbGui
|
|
56
60
|
run_io_command(db_command)
|
57
61
|
end
|
58
62
|
|
63
|
+
def db_command_result_count
|
64
|
+
db_command_result_count_headers_rows[0]
|
65
|
+
end
|
66
|
+
|
67
|
+
def db_command_result_headers
|
68
|
+
db_command_result_count_headers_rows[1]
|
69
|
+
end
|
70
|
+
|
71
|
+
def db_command_result_rows
|
72
|
+
db_command_result_count_headers_rows[2]
|
73
|
+
end
|
74
|
+
|
59
75
|
private
|
60
76
|
|
61
77
|
def read_io_into_db_command_result
|
@@ -86,11 +102,32 @@ class DbGui
|
|
86
102
|
|
87
103
|
def io_gets
|
88
104
|
# TODO figure out a way of knowing the end of input without timing out
|
89
|
-
Timeout.timeout(
|
105
|
+
Timeout.timeout(db_command_timeout/1000.0) { io.gets }
|
90
106
|
rescue
|
91
107
|
@io = nil
|
92
108
|
nil
|
93
109
|
end
|
110
|
+
|
111
|
+
def db_command_result_count_headers_rows
|
112
|
+
if @db_command_result_count_headers_rows.nil? || db_command_result != @last_db_command_result
|
113
|
+
count = 0
|
114
|
+
headers = rows = []
|
115
|
+
db_command_result_lines = db_command_result.lines
|
116
|
+
db_command_result_lines.pop if db_command_result_lines.last == "\n"
|
117
|
+
if db_command_result_lines.any?
|
118
|
+
headers = db_command_result_lines.first.split('|').map(&:strip)
|
119
|
+
count_footer = db_command_result_lines.last
|
120
|
+
count_match = count_footer.match(/^\((\d+) row/)
|
121
|
+
if count_match
|
122
|
+
count = count_match[1].to_i
|
123
|
+
rows = db_command_result_lines[2..-2].map {|row| row.split('|').map(&:strip) }
|
124
|
+
end
|
125
|
+
end
|
126
|
+
@db_command_result_count_headers_rows = [count, headers, rows]
|
127
|
+
@last_db_command_result = db_command_result
|
128
|
+
end
|
129
|
+
@db_command_result_count_headers_rows
|
130
|
+
end
|
94
131
|
end
|
95
132
|
end
|
96
133
|
end
|
@@ -5,6 +5,8 @@ class DbGui
|
|
5
5
|
class DbCommandForm
|
6
6
|
include Glimmer::LibUI::CustomControl
|
7
7
|
|
8
|
+
TIMEOUT_MAX_IN_MILLISECONDS = (ENV['TIMEOUT_MAX_IN_MILLISECONDS'] || 60*60*1000).to_i
|
9
|
+
|
8
10
|
option :db_config
|
9
11
|
|
10
12
|
body {
|
@@ -13,12 +15,30 @@ class DbGui
|
|
13
15
|
text <=> [db_config, :db_command]
|
14
16
|
}
|
15
17
|
|
16
|
-
|
18
|
+
horizontal_box {
|
17
19
|
stretchy false
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
20
|
+
|
21
|
+
button('Run') {
|
22
|
+
on_clicked do
|
23
|
+
db_config.run_db_command
|
24
|
+
end
|
25
|
+
}
|
26
|
+
|
27
|
+
label('Timeout (msec): ') {
|
28
|
+
stretchy false
|
29
|
+
}
|
30
|
+
spinbox(0, TIMEOUT_MAX_IN_MILLISECONDS) {
|
31
|
+
stretchy false
|
32
|
+
value <=> [db_config, :db_command_timeout]
|
33
|
+
}
|
34
|
+
|
35
|
+
label('Row(s): ') {
|
36
|
+
stretchy false
|
37
|
+
}
|
38
|
+
label {
|
39
|
+
stretchy false
|
40
|
+
text <= [db_config, :db_command_result_count, computed_by: :db_command_result, on_read: :to_s]
|
41
|
+
}
|
22
42
|
}
|
23
43
|
}
|
24
44
|
}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'db_gui/model/db_config'
|
2
|
+
|
3
|
+
class DbGui
|
4
|
+
module View
|
5
|
+
class DbCommandResultTable
|
6
|
+
include Glimmer::LibUI::CustomControl
|
7
|
+
|
8
|
+
option :db_config
|
9
|
+
|
10
|
+
body {
|
11
|
+
vertical_box {
|
12
|
+
content(db_config, :db_command_result) {
|
13
|
+
if db_config.db_command_result_count > 0
|
14
|
+
table {
|
15
|
+
db_config.db_command_result_headers.each do |header|
|
16
|
+
text_column(header)
|
17
|
+
end
|
18
|
+
|
19
|
+
cell_rows db_config.db_command_result_rows
|
20
|
+
}
|
21
|
+
else
|
22
|
+
label('No data')
|
23
|
+
end
|
24
|
+
}
|
25
|
+
}
|
26
|
+
}
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
@@ -13,26 +13,31 @@ class DbGui
|
|
13
13
|
entry {
|
14
14
|
label 'Host:'
|
15
15
|
text <=> [db_config, :host]
|
16
|
+
enabled <= [db_config, :connected, on_read: :!]
|
16
17
|
}
|
17
18
|
|
18
19
|
spinbox(0, 1_000_000) {
|
19
20
|
label 'Port:'
|
20
21
|
value <=> [db_config, :port]
|
22
|
+
enabled <= [db_config, :connected, on_read: :!]
|
21
23
|
}
|
22
24
|
|
23
25
|
entry {
|
24
26
|
label 'Database Name:'
|
25
27
|
text <=> [db_config, :dbname]
|
28
|
+
enabled <= [db_config, :connected, on_read: :!]
|
26
29
|
}
|
27
30
|
|
28
31
|
entry {
|
29
32
|
label 'Username:'
|
30
33
|
text <=> [db_config, :username]
|
34
|
+
enabled <= [db_config, :connected, on_read: :!]
|
31
35
|
}
|
32
36
|
|
33
37
|
password_entry {
|
34
38
|
label 'Password:'
|
35
39
|
text <=> [db_config, :password]
|
40
|
+
enabled <= [db_config, :connected, on_read: :!]
|
36
41
|
}
|
37
42
|
}
|
38
43
|
|
@@ -2,6 +2,7 @@ require 'db_gui/presenter/db_gui_presenter'
|
|
2
2
|
|
3
3
|
require 'db_gui/view/db_config_form'
|
4
4
|
require 'db_gui/view/db_command_form'
|
5
|
+
require 'db_gui/view/db_command_result_table'
|
5
6
|
|
6
7
|
class DbGui
|
7
8
|
module View
|
@@ -29,9 +30,7 @@ class DbGui
|
|
29
30
|
|
30
31
|
db_command_form(db_config: presenter.db_config)
|
31
32
|
|
32
|
-
|
33
|
-
text <=> [presenter.db_config, :db_command_result, on_write: ->(value) {presenter.db_config.db_command_result}]
|
34
|
-
}
|
33
|
+
db_command_result_table(db_config: presenter.db_config)
|
35
34
|
}
|
36
35
|
}
|
37
36
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: db-gui
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Maleh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-03-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: glimmer-dsl-libui
|
@@ -66,7 +66,8 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
-
description:
|
69
|
+
description: DB GUI (Database Graphical User Interface) - Enables Interaction with
|
70
|
+
Relational SQL Databases
|
70
71
|
email: andy.am@gmail.com
|
71
72
|
executables:
|
72
73
|
- db-gui
|
@@ -88,6 +89,7 @@ files:
|
|
88
89
|
- app/db_gui/model/db_config.rb
|
89
90
|
- app/db_gui/presenter/db_gui_presenter.rb
|
90
91
|
- app/db_gui/view/db_command_form.rb
|
92
|
+
- app/db_gui/view/db_command_result_table.rb
|
91
93
|
- app/db_gui/view/db_config_form.rb
|
92
94
|
- app/db_gui/view/db_gui_application.rb
|
93
95
|
- bin/db-gui
|
@@ -117,8 +119,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
117
119
|
- !ruby/object:Gem::Version
|
118
120
|
version: '0'
|
119
121
|
requirements: []
|
120
|
-
rubygems_version: 3.4.
|
122
|
+
rubygems_version: 3.4.19
|
121
123
|
signing_key:
|
122
124
|
specification_version: 4
|
123
|
-
summary:
|
125
|
+
summary: DB GUI
|
124
126
|
test_files: []
|