sqlui 0.1.15 → 0.1.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.version +1 -1
- data/app/environment.rb +20 -0
- data/app/server.rb +3 -1
- data/app/sqlui.rb +65 -64
- data/app/views/databases.erb +2 -2
- data/{resources → client/resources}/sqlui.css +0 -0
- data/{resources → client/resources}/sqlui.html +0 -0
- data/{resources → client/resources}/sqlui.js +0 -0
- metadata +21 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7c438724dd4d58432da2908650a10bb82c3452a2faf4f0560c5dd23a8fd6d66
|
4
|
+
data.tar.gz: 949a64296520f3e7fcfec48ae1a4cc8b4a4056184d88a88ca52b5813b1ad8064
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab6348bdcbeb1b2dfd7e38c206b7d72bf388f28ae992e15c40823b00db1bc3bdfb705cc3764373ca0f1de053b32ea546f84bdacf99328b5b6def0f9aea40954e
|
7
|
+
data.tar.gz: a55564765cd9c90fe47ef06d521aefde3bc78f903527cd4a49b6817267364ff6cd609d47b645a9508c382fcc1798b355b414b12ea861782038b538dbaa90a861
|
data/.version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.16
|
data/app/environment.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
class Environment
|
2
|
+
SERVER_ENV = ENV.fetch('SERVER_ENV', 'development').to_sym
|
3
|
+
SERVER_PORT = ENV.fetch('SERVER_PORT', 8080)
|
4
|
+
|
5
|
+
def self.server_env
|
6
|
+
SERVER_ENV
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.development?
|
10
|
+
SERVER_ENV == :development
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.production?
|
14
|
+
SERVER_ENV == :production
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.server_port
|
18
|
+
SERVER_PORT
|
19
|
+
end
|
20
|
+
end
|
data/app/server.rb
CHANGED
@@ -4,6 +4,7 @@ require 'mysql2'
|
|
4
4
|
require 'sinatra/base'
|
5
5
|
require_relative 'sqlui'
|
6
6
|
require 'yaml'
|
7
|
+
require_relative 'environment'
|
7
8
|
|
8
9
|
if ARGV.include?('-v') || ARGV.include?('--version')
|
9
10
|
puts File.read('.version')
|
@@ -16,7 +17,8 @@ raise "configuration file does not exist" unless File.exist?(ARGV[0])
|
|
16
17
|
class Server < Sinatra::Base
|
17
18
|
set :logging, true
|
18
19
|
set :bind, '0.0.0.0'
|
19
|
-
set :port,
|
20
|
+
set :port, Environment.server_port
|
21
|
+
set :env, Environment.server_env
|
20
22
|
|
21
23
|
class Client
|
22
24
|
def initialize(params)
|
data/app/sqlui.rb
CHANGED
@@ -11,7 +11,7 @@ class SQLUI
|
|
11
11
|
@name = name
|
12
12
|
@saved_path = saved_path
|
13
13
|
@max_rows = max_rows
|
14
|
-
@resources_dir = File.join(File.expand_path('..', File.dirname(__FILE__)), 'resources')
|
14
|
+
@resources_dir = File.join(File.expand_path('..', File.dirname(__FILE__)), 'client', 'resources')
|
15
15
|
end
|
16
16
|
|
17
17
|
def get(params)
|
@@ -78,25 +78,6 @@ class SQLUI
|
|
78
78
|
end
|
79
79
|
|
80
80
|
def load_metadata
|
81
|
-
if @table_schema
|
82
|
-
where_clause = "where table_schema = '#{@table_schema}'"
|
83
|
-
else
|
84
|
-
where_clause = "where table_schema not in('mysql', 'sys')"
|
85
|
-
end
|
86
|
-
stats_result = @client.query(
|
87
|
-
<<~SQL
|
88
|
-
select
|
89
|
-
table_schema,
|
90
|
-
table_name,
|
91
|
-
index_name,
|
92
|
-
seq_in_index,
|
93
|
-
non_unique,
|
94
|
-
column_name
|
95
|
-
from information_schema.statistics
|
96
|
-
#{where_clause}
|
97
|
-
order by table_schema, table_name, if(index_name = "PRIMARY", 0, index_name), seq_in_index;
|
98
|
-
SQL
|
99
|
-
)
|
100
81
|
result = {
|
101
82
|
server: @name,
|
102
83
|
schemas: {},
|
@@ -107,40 +88,11 @@ class SQLUI
|
|
107
88
|
}
|
108
89
|
end
|
109
90
|
}
|
110
|
-
stats_result.each do |row|
|
111
|
-
table_schema = row['table_schema']
|
112
|
-
unless result[:schemas][table_schema]
|
113
|
-
result[:schemas][table_schema] = {
|
114
|
-
tables: {}
|
115
|
-
}
|
116
|
-
end
|
117
|
-
tables = result[:schemas][table_schema][:tables]
|
118
|
-
table_name = row['table_name']
|
119
|
-
unless tables[table_name]
|
120
|
-
tables[table_name] = {
|
121
|
-
indexes: {},
|
122
|
-
columns: {}
|
123
|
-
}
|
124
|
-
end
|
125
|
-
indexes = tables[table_name][:indexes]
|
126
|
-
index_name = row['index_name']
|
127
|
-
unless indexes[index_name]
|
128
|
-
indexes[index_name] = {}
|
129
|
-
end
|
130
|
-
index = indexes[index_name]
|
131
|
-
column_name = row['column_name']
|
132
|
-
index[column_name] = {}
|
133
|
-
column = index[column_name]
|
134
|
-
column[:name] = index_name
|
135
|
-
column[:seq_in_index] = row['seq_in_index']
|
136
|
-
column[:non_unique] = row['non_unique']
|
137
|
-
column[:column_name] = row['column_name']
|
138
|
-
end
|
139
91
|
|
140
92
|
if @table_schema
|
141
93
|
where_clause = "where table_schema = '#{@table_schema}'"
|
142
94
|
else
|
143
|
-
where_clause = "where table_schema not in('
|
95
|
+
where_clause = "where table_schema not in('mysql', 'sys', 'information_schema', 'performance_schema')"
|
144
96
|
end
|
145
97
|
column_result = @client.query(
|
146
98
|
<<~SQL
|
@@ -155,29 +107,78 @@ class SQLUI
|
|
155
107
|
column_default,
|
156
108
|
extra
|
157
109
|
from information_schema.columns
|
158
|
-
|
110
|
+
#{where_clause}
|
159
111
|
order by table_schema, table_name, column_name, ordinal_position;
|
160
|
-
|
112
|
+
SQL
|
161
113
|
)
|
162
114
|
column_result.each do |row|
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
115
|
+
row = row.transform_keys(&:downcase).transform_keys(&:to_sym)
|
116
|
+
table_schema = row[:table_schema]
|
117
|
+
unless result[:schemas][table_schema]
|
118
|
+
result[:schemas][table_schema] = {
|
119
|
+
tables: {}
|
120
|
+
}
|
121
|
+
end
|
122
|
+
table_name = row[:table_name]
|
123
|
+
tables = result[:schemas][table_schema][:tables]
|
124
|
+
unless tables[table_name]
|
125
|
+
tables[table_name] = {
|
126
|
+
indexes: {},
|
127
|
+
columns: {}
|
128
|
+
}
|
129
|
+
end
|
169
130
|
columns = result[:schemas][table_schema][:tables][table_name][:columns]
|
131
|
+
column_name = row[:column_name]
|
170
132
|
unless columns[column_name]
|
171
133
|
columns[column_name] = {}
|
172
134
|
end
|
173
135
|
column = columns[column_name]
|
174
136
|
column[:name] = column_name
|
175
|
-
column[:data_type] = row[
|
176
|
-
column[:length] = row[
|
177
|
-
column[:allow_null] = row[
|
178
|
-
column[:key] = row[
|
179
|
-
column[:default] = row[
|
180
|
-
column[:extra] = row[
|
137
|
+
column[:data_type] = row[:data_type]
|
138
|
+
column[:length] = row[:character_maximum_length]
|
139
|
+
column[:allow_null] = row[:is_nullable]
|
140
|
+
column[:key] = row[:column_key]
|
141
|
+
column[:default] = row[:column_default]
|
142
|
+
column[:extra] = row[:extra]
|
143
|
+
end
|
144
|
+
|
145
|
+
if @table_schema
|
146
|
+
where_clause = "where table_schema = '#{@table_schema}'"
|
147
|
+
else
|
148
|
+
where_clause = "where table_schema not in('mysql', 'sys', 'information_schema', 'performance_schema')"
|
149
|
+
end
|
150
|
+
stats_result = @client.query(
|
151
|
+
<<~SQL
|
152
|
+
select
|
153
|
+
table_schema,
|
154
|
+
table_name,
|
155
|
+
index_name,
|
156
|
+
seq_in_index,
|
157
|
+
non_unique,
|
158
|
+
column_name
|
159
|
+
from information_schema.statistics
|
160
|
+
#{where_clause}
|
161
|
+
order by table_schema, table_name, if(index_name = "PRIMARY", 0, index_name), seq_in_index;
|
162
|
+
SQL
|
163
|
+
)
|
164
|
+
stats_result.each do |row|
|
165
|
+
row = row.transform_keys(&:downcase).transform_keys(&:to_sym)
|
166
|
+
table_schema = row[:table_schema]
|
167
|
+
tables = result[:schemas][table_schema][:tables]
|
168
|
+
table_name = row[:table_name]
|
169
|
+
indexes = tables[table_name][:indexes]
|
170
|
+
index_name = row[:index_name]
|
171
|
+
unless indexes[index_name]
|
172
|
+
indexes[index_name] = {}
|
173
|
+
end
|
174
|
+
index = indexes[index_name]
|
175
|
+
column_name = row[:column_name]
|
176
|
+
index[column_name] = {}
|
177
|
+
column = index[column_name]
|
178
|
+
column[:name] = index_name
|
179
|
+
column[:seq_in_index] = row[:seq_in_index]
|
180
|
+
column[:non_unique] = row[:non_unique]
|
181
|
+
column[:column_name] = row[:column_name]
|
181
182
|
end
|
182
183
|
|
183
184
|
result
|
data/app/views/databases.erb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
<html>
|
2
2
|
<head>
|
3
|
-
<title>
|
3
|
+
<title>Databases</title>
|
4
4
|
|
5
5
|
<style>
|
6
6
|
body {
|
@@ -49,7 +49,7 @@
|
|
49
49
|
</head>
|
50
50
|
|
51
51
|
<body>
|
52
|
-
<h1>
|
52
|
+
<h1>Databases</h1>
|
53
53
|
<% databases.values.each do |database| %>
|
54
54
|
<div class="database" onclick="window.location='<%= "/db/#{database['url_path']}/app" %>'">
|
55
55
|
<h2><%= database['name'] %></h2>
|
File without changes
|
File without changes
|
File without changes
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sqlui
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Dower
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-10-
|
11
|
+
date: 2022-10-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mysql2
|
@@ -122,6 +122,20 @@ dependencies:
|
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '3.0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: watir
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '7.0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '7.0'
|
125
139
|
description: A SQL UI.
|
126
140
|
email: nicholasdower@gmail.com
|
127
141
|
executables:
|
@@ -130,13 +144,14 @@ extensions: []
|
|
130
144
|
extra_rdoc_files: []
|
131
145
|
files:
|
132
146
|
- ".version"
|
147
|
+
- app/environment.rb
|
133
148
|
- app/server.rb
|
134
149
|
- app/sqlui.rb
|
135
150
|
- app/views/databases.erb
|
136
151
|
- bin/sqlui
|
137
|
-
- resources/sqlui.css
|
138
|
-
- resources/sqlui.html
|
139
|
-
- resources/sqlui.js
|
152
|
+
- client/resources/sqlui.css
|
153
|
+
- client/resources/sqlui.html
|
154
|
+
- client/resources/sqlui.js
|
140
155
|
homepage: https://github.com/nicholasdower/sqlui
|
141
156
|
licenses:
|
142
157
|
- MIT
|
@@ -156,7 +171,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
156
171
|
- !ruby/object:Gem::Version
|
157
172
|
version: '0'
|
158
173
|
requirements: []
|
159
|
-
rubygems_version: 3.
|
174
|
+
rubygems_version: 3.2.3
|
160
175
|
signing_key:
|
161
176
|
specification_version: 4
|
162
177
|
summary: A SQL UI.
|