line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
2
|
|
|
2
|
|
24778
|
use 5.008007; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
129
|
|
2
|
|
|
|
|
|
|
package Mojolicious::Plugin::SQLiteViewerLite; |
3
|
2
|
|
|
2
|
|
428
|
use Mojo::Base 'Mojolicious::Plugin::SQLiteViewerLite::Base'; |
|
2
|
|
|
|
|
7203
|
|
|
2
|
|
|
|
|
17
|
|
4
|
2
|
|
|
2
|
|
2036
|
use Mojolicious::Plugin::SQLiteViewerLite::Command; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
29
|
|
5
|
2
|
|
|
2
|
|
85
|
use DBIx::Custom; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
19
|
|
6
|
2
|
|
|
2
|
|
69
|
use Validator::Custom; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
15
|
|
7
|
2
|
|
|
2
|
|
61
|
use File::Basename 'dirname'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
142
|
|
8
|
2
|
|
|
2
|
|
16
|
use Cwd 'abs_path'; |
|
2
|
|
|
|
|
15
|
|
|
2
|
|
|
|
|
1079
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.13'; |
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
|
2
|
|
|
2
|
1
|
13156
|
my ($self, $app, $conf) = @_; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# Database |
21
|
2
|
|
|
|
|
7
|
my $dbi = $conf->{dbi}; |
22
|
2
|
|
|
|
|
6
|
my $connector = $conf->{connector}; |
23
|
2
|
|
|
|
|
5
|
my $dbh = $conf->{dbh}; |
24
|
2
|
100
|
|
|
|
12
|
if ($dbi) { $self->dbi($dbi) } |
|
1
|
50
|
|
|
|
13
|
|
25
|
0
|
|
|
|
|
0
|
elsif ($connector) { $self->dbi->connector($connector) } |
26
|
1
|
|
|
|
|
11
|
else { $self->dbi->dbh($dbh) } |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# Add template and public path |
29
|
2
|
|
|
|
|
268
|
$self->add_template_path($app->renderer, __PACKAGE__); |
30
|
2
|
|
|
|
|
45
|
$self->add_static_path($app->static, __PACKAGE__); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# Routes |
33
|
2
|
|
66
|
|
|
43
|
my $r = $conf->{route} // $app->routes; |
34
|
2
|
|
100
|
|
|
29
|
my $prefix = $conf->{prefix} // 'sqliteviewerlite'; |
35
|
2
|
|
|
|
|
16
|
$self->prefix($prefix); |
36
|
|
|
|
|
|
|
{ |
37
|
2
|
|
|
|
|
14
|
my $r = $r->route("/$prefix")->to( |
|
2
|
|
|
|
|
18
|
|
38
|
|
|
|
|
|
|
'sqliteviewerlite#', |
39
|
|
|
|
|
|
|
namespace => 'Mojolicious::Plugin::SQLiteViewerLite', |
40
|
|
|
|
|
|
|
plugin => $self, |
41
|
|
|
|
|
|
|
prefix => $self->prefix, |
42
|
|
|
|
|
|
|
main_title => 'SQLite Viewer Lite', |
43
|
|
|
|
|
|
|
); |
44
|
|
|
|
|
|
|
|
45
|
2
|
|
|
|
|
709
|
$r->get('/')->to('#default'); |
46
|
2
|
|
|
|
|
347
|
$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
|
2
|
|
|
|
|
464
|
$r->get('/table')->to('#table'); |
56
|
2
|
|
|
|
|
593
|
$r->get('/showcreatetables')->to('#showcreatetables'); |
57
|
2
|
|
|
|
|
608
|
$r->get('/showselecttables')->to('#showselecttables'); |
58
|
2
|
|
|
|
|
540
|
$r->get('/showprimarykeys')->to('#showprimarykeys'); |
59
|
2
|
|
|
|
|
511
|
$r->get('/shownullallowedcolumns')->to('#shownullallowedcolumns'); |
60
|
2
|
|
|
|
|
579
|
$r->get('/showdatabaseengines')->to('#showdatabaseengines'); |
61
|
2
|
|
|
|
|
605
|
$r->get('/showcharsets')->to('#showcharsets'); |
62
|
2
|
|
|
|
|
633
|
$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 |