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