blib/lib/SQL/sql_loader_example.pl untested

filter: Statementstmt 0.0% 0 / 30 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 47 CC 1 SCAR 6.9
CC
1
Cov
0%
_usage
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 #!/usr/bin/perl
2  
3 use strict;
4 use warnings;
5  
6 =head1 NAME
7  
8 sql_loader_example.pl
9  
10 =head1 SYNOPSIS
11  
12 perl sql_loader_example.pl --url=<schema url> --dbname=<dbname> --dbuser=<dbuser> --dbpass=<dbpass> [ --quiet ]
13  
14 perl sql_loader_example.pl --url=<schema url> --print_http_headers
15  
16 perl sql_loader_example.pl --help
17  
18 =head2 Arguments:
19  
20 - Pass the url to use to scrape db schema from with --url flag.
21 - specify dbname with --dbname
22 - specify dbuser with --dbuser
23 - specify dbpass with --dbpass
24 - show this screen and exit with --help
25 - Test server response by requesting headers only with --print_http_headers flag ( does not rebuild db )
26 - do not print any informational messages with --quiet option
27  
28 The database specified by dbname must already exist and note that this script DROPS all existing tables found, as it is assumed if you are running this script you are either creating a new db for first time or you are rebuilding your db for testing/development purposes.
29  
30 =head1 DESCRIPTION
31  
32 screen scrape db schema from intranet and create sql to load into db.
33  
34 =head1 SEE ALSO
35  
36 L<SQL::Loader>
37  
38 =cut
39  
40 use lib qw( ./lib );
41  
42 use Getopt::Long;
43 use SQL::Loader::MySQL;
44  
45 my $url;
46 my $print_http_headers;
47 my $dbname;
48 my $dbuser;
49 my $dbpass;
50 my $help;
51 my $quiet;
52  
53 my $args = GetOptions(
54 "url=s" => \$url, # string
55 "dbname=s" => \$dbname,
56 "dbuser=s" => \$dbuser,
57 "dbpass=s" => \$dbpass,
58 "print_http_headers" => \$print_http_headers,
59 "help" => \$help,
60 "quiet" => \$quiet
61 );
62  
63 if ($help) {
64 _usage();
65 }
66  
67 $print_http_headers ||= 0;
68  
69 my $loader = SQL::Loader::MySQL->new(
70 url => $url,
71 dbname => $dbname,
72 dbuser => $dbuser,
73 dbpass => $dbpass,
74 print_http_headers => $print_http_headers || 0,
75 quiet => $quiet || 0
76 );
77 $loader->run;
78  
79 sub _usage {
80 print <<EOF;
81 Usage:
82  
83 perl $0 --url=<schema url> --dbname=<dbname> --dbuser=<dbuser> --dbpass=<dbpass> [ --quiet ]
84  
85 perl $0 --url=<schema url> --print_http_headers
86  
87 perl $0 --help
88  
89 Arguments:
90  
91 - Pass the url to use to scrape db schema from with --url flag.
92 - specify dbname with --dbname
93 - specify dbuser with --dbuser
94 - specify dbpass with --dbpass
95 - show this screen and exit with --help
96 - Test server response by requesting headers only with --print_http_headers flag ( does not rebuild db )
97 - do not print any informational messages with --quiet option
98  
99 The database specified by dbname must already exist and note that this script DROPS all existing tables found, as it is assumed if you are running this script you are either creating a new db for first time or you are rebuilding your db for testing/development purposes.
100  
101 See also: perldoc $0
102 EOF
103  
104 exit 0;
105 }
106  
107 __END__