File Coverage

lib/SQL/Admin/Driver/Base/DBI.pm
Criterion Covered Total %
statement 12 28 42.8
branch 0 4 0.0
condition 0 11 0.0
subroutine 4 11 36.3
pod 0 7 0.0
total 16 61 26.2


line stmt bran cond sub pod time code
1              
2             package SQL::Admin::Driver::Base::DBI;
3              
4 1     1   1654 use strict;
  1         2  
  1         37  
5 1     1   5 use warnings;
  1         2  
  1         42  
6              
7             our $VERSION = v0.5.0;
8              
9             ######################################################################
10              
11 1     1   2795 use DBI;
  1         54566  
  1         91  
12 1     1   1717 use SQL::Abstract;
  1         14686  
  1         383  
13              
14             my $sqla;
15              
16             ######################################################################
17             ######################################################################
18             sub new { # ;
19 0     0 0   my $class = shift;
20 0   0       bless { @_ }, ref $class || $class;
21             }
22              
23              
24             ######################################################################
25             ######################################################################
26             sub options { # ;
27             (
28 0     0 0   'dbdns=s',
29             'dbusr=s',
30             'dbpwd=s',
31             );
32             }
33              
34              
35             ######################################################################
36             ######################################################################
37             sub sqla { # ;
38 0   0 0 0   $sqla ||= SQL::Abstract->new;
39             }
40              
41              
42             ######################################################################
43             ######################################################################
44             sub dbh { # ;
45 0     0 0   my $self = shift;
46 0 0         $self->{dbh} || $self->connect;
47             }
48              
49              
50             ######################################################################
51             ######################################################################
52             sub execute { # ;
53 0     0 0   my ($self, $sql, @bind) = @_;
54              
55 0           my $sth = $self->dbh->prepare ($sql);
56 0           $sth->execute (@bind);
57              
58 0           $sth;
59             }
60              
61              
62             ######################################################################
63             ######################################################################
64             sub connect { # ;
65 0     0 0   my ($self, $dsn, $user, $password) = @_;
66              
67 0   0       $self->{dbh} ||= DBI->connect (
      0        
68             $dsn || $self->{dbdsn},
69             $user || $self->{dbusr},
70             $password || $self->{dbpwd},
71             { FetchHashKeyName => 'NAME_lc' },
72             ) || die "Unable to connect: $DBI::errstr";
73             }
74              
75              
76             ######################################################################
77             ######################################################################
78             sub load { # ;
79 0     0 0   my ($self, $catalog, @params) = @_;
80 0 0         $self->connect || return;
81              
82 0           map $self->$_ ($catalog, @params),
83             grep $self->can ($_), (
84             'load_sequence',
85             'load_table',
86             'load_index',
87             'load_table_column',
88             'load_table_column_not_null',
89             'load_table_column_default',
90             'load_table_column_autoincrement',
91             'load_constraint_primary_key',
92             'load_constraint_unique',
93             'load_constraint_foreign_key',
94             'load_constraint_check',
95             # 'load_view',
96             # 'load_function',
97             # 'load_trigger',
98             # 'load_rule',
99             );
100              
101 0           1;
102             }
103              
104              
105             ######################################################################
106             ######################################################################
107              
108             package SQL::Admin::Driver::Base::DBI;
109              
110             1;
111