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