line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
766
|
use 5.001001; |
|
1
|
|
|
|
|
3
|
|
2
|
|
|
|
|
|
|
package Mojolicious::Plugin::MySQLViewerLite; |
3
|
1
|
|
|
1
|
|
644
|
use Mojo::Base 'Mojolicious::Plugin::MySQLViewerLite::Base'; |
|
1
|
|
|
|
|
176139
|
|
|
1
|
|
|
|
|
9
|
|
4
|
1
|
|
|
1
|
|
72
|
use File::Basename 'dirname'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
37
|
|
5
|
1
|
|
|
1
|
|
6
|
use Cwd 'abs_path'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
54
|
|
6
|
1
|
|
|
1
|
|
598
|
use Mojolicious::Plugin::MySQLViewerLite::Command; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
12
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.17'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has command => sub { |
11
|
|
|
|
|
|
|
my $self = shift; |
12
|
|
|
|
|
|
|
my $commond = Mojolicious::Plugin::MySQLViewerLite::Command->new(dbi => $self->dbi); |
13
|
|
|
|
|
|
|
}; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub register { |
16
|
0
|
|
|
0
|
1
|
|
my ($self, $app, $conf) = @_; |
17
|
0
|
|
0
|
|
|
|
my $prefix = $conf->{prefix} // 'mysqlviewerlite'; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# Database |
20
|
0
|
|
|
|
|
|
my $dbi = $conf->{dbi}; |
21
|
0
|
|
|
|
|
|
my $connector = $conf->{connector}; |
22
|
0
|
|
|
|
|
|
my $dbh = $conf->{dbh}; |
23
|
0
|
0
|
|
|
|
|
if ($dbi) { $self->dbi($dbi) } |
|
0
|
0
|
|
|
|
|
|
24
|
0
|
|
|
|
|
|
elsif ($connector) { $self->dbi->connector($connector) } |
25
|
0
|
|
|
|
|
|
else { $self->dbi->dbh($dbh) } |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# Add template and static path |
28
|
0
|
|
|
|
|
|
$self->add_template_path($app->renderer, __PACKAGE__); |
29
|
0
|
|
|
|
|
|
$self->add_static_path($app->static, __PACKAGE__); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# Mojolicious compatibility |
32
|
0
|
|
|
|
|
|
my $any_method_name; |
33
|
0
|
0
|
|
|
|
|
if ($Mojolicious::VERSION >= '8.67') { |
34
|
0
|
|
|
|
|
|
$any_method_name = 'any' |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
else { |
37
|
0
|
|
|
|
|
|
$any_method_name = 'route' |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# Routes |
41
|
0
|
|
0
|
|
|
|
my $r = $conf->{route} // $app->routes; |
42
|
0
|
|
|
|
|
|
$self->prefix($prefix); |
43
|
|
|
|
|
|
|
{ |
44
|
0
|
|
|
|
|
|
my $r = $r->$any_method_name("/$prefix")->to( |
|
0
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
'mysqlviewerlite#', |
46
|
|
|
|
|
|
|
namespace => 'Mojolicious::Plugin::MySQLViewerLite', |
47
|
|
|
|
|
|
|
plugin => $self, |
48
|
|
|
|
|
|
|
prefix => $self->prefix, |
49
|
|
|
|
|
|
|
main_title => 'MySQL Viewer Lite', |
50
|
|
|
|
|
|
|
); |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
$r->get('/')->to('#default'); |
53
|
0
|
|
|
|
|
|
$r->get('/tables')->to( |
54
|
|
|
|
|
|
|
'#tables', |
55
|
|
|
|
|
|
|
utilities => [ |
56
|
|
|
|
|
|
|
{path => 'showcreatetables', title => 'Show create tables'}, |
57
|
|
|
|
|
|
|
{path => 'showselecttables', title => 'Show select tables'}, |
58
|
|
|
|
|
|
|
{path => 'showprimarykeys', title => 'Show primary keys'}, |
59
|
|
|
|
|
|
|
{path => 'shownullallowedcolumns', title => 'Show null allowed columns'}, |
60
|
|
|
|
|
|
|
{path => 'showdatabaseengines', title => 'Show database engines'}, |
61
|
|
|
|
|
|
|
{path => 'showcharsets', title => 'Show charsets'} |
62
|
|
|
|
|
|
|
] |
63
|
|
|
|
|
|
|
); |
64
|
0
|
|
|
|
|
|
$r->get('/table')->to('#table'); |
65
|
0
|
|
|
|
|
|
$r->get('/showcreatetables')->to('#showcreatetables'); |
66
|
0
|
|
|
|
|
|
$r->get('/showselecttables')->to('#showselecttables'); |
67
|
0
|
|
|
|
|
|
$r->get('/showprimarykeys')->to('#showprimarykeys'); |
68
|
0
|
|
|
|
|
|
$r->get('/shownullallowedcolumns')->to('#shownullallowedcolumns'); |
69
|
0
|
|
|
|
|
|
$r->get('/showdatabaseengines')->to('#showdatabaseengines'); |
70
|
0
|
|
|
|
|
|
$r->get('/showcharsets')->to('#showcharsets'); |
71
|
0
|
|
|
|
|
|
$r->get('/select')->to('#select'); |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
# Routes (MySQL specific) |
74
|
0
|
|
|
|
|
|
$r->get('/showdatabaseengines')->to('#showdatabaseengines'); |
75
|
0
|
|
|
|
|
|
$r->get('/showcharsets')->to('#showcharsets'); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
1; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 NAME |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Mojolicious::Plugin::MySQLViewerLite - Mojolicious plugin to display MySQL database information on browser |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 CAUTION |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
B is merged into L>. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
B. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
But you get it on github. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
https://github.com/yuki-kimoto/Mojolicious-Plugin-MySQLViewerLite |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 SYNOPSYS |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
# Mojolicious::Lite |
98
|
|
|
|
|
|
|
# (dbh is a database handle already connected to the database) |
99
|
|
|
|
|
|
|
plugin 'MySQLViewerLite', dbh => $dbh; |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
# Mojolicious |
102
|
|
|
|
|
|
|
$app->plugin('MySQLViewerLite', dbh => $dbh); |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
# Access |
105
|
|
|
|
|
|
|
http://localhost:3000/mysqlviewerlite |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
# Prefix |
108
|
|
|
|
|
|
|
plugin 'MySQLViewerLite', dbh => $dbh, prefix => 'mysqlviewerlite2'; |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
# Route |
111
|
|
|
|
|
|
|
my $bridge = $app->route->under(sub {...}); |
112
|
|
|
|
|
|
|
plugin 'MySQLViewerLite', dbh => $dbh, route => $bridge; |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
# Using connection manager object instead of "dbh" |
115
|
|
|
|
|
|
|
plugin 'MySQLViewerLite', connector => DBIx::Connector->connect(...); |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
# Using DBIx::Custom object instead of "dbh" |
118
|
|
|
|
|
|
|
plugin 'MySQLViewerLite', dbi => DBIx::Custom->connect(...); |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 DESCRIPTION |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
L is L plugin |
123
|
|
|
|
|
|
|
to display MySQL database information on your browser. |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
L have the following features. |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=over 4 |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=item * |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
Display all table names |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=item * |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
Display C |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=item * |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
Select * from TABLE |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=item * |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
Display C, C, C and C in all tables. |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=back |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head1 OPTIONS |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head2 C |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
connector => $connector |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
Connector object such as L to connect to database. |
154
|
|
|
|
|
|
|
You can use this instead of C option. |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
my $connector = DBIx::Connector->connect(...); |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
Connector has C method to get database handle |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=head2 C |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
dbh => $dbh |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
dbh is a L database handle already connected to the database. |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
my $dbh = DBI->connect(...); |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=head2 C |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
dbi => DBIx::Custom->connect(...); |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
L object. |
173
|
|
|
|
|
|
|
you can use this instead of C option. |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=head2 C |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
prefix => 'mysqlviewerlite2' |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
Application base path, default to C. |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=head2 C |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
route => $route |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
Router, default to C<$app->routes>. |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
It is useful when C is used. |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
my $bridge = $r->under(sub {...}); |
190
|
|
|
|
|
|
|
plugin 'MySQLViewerLite', dbh => $dbh, route => $bridge; |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=cut |