MtPolicyd/Connection/Sql.pm

filter: Statementstmt 90.0% 18 / 20 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 80.0% 4 / 5 Podpod 0.0% 0 / 1 totaltotal 84.6% 22 / 26 CC 1 SCAR 1.8
CC
1
Cov
90%
reconnect
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
« MtPolicyd/Plugin/SetField.pm ↑ Summary MtPolicyd/AddressList.pm »
1 package Mail::MtPolicyd::Connection::Sql;
2  
3 5 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 5 extends 'Mail::MtPolicyd::Connection';
6  
7 # ABSTRACT: Connection pool sql connection object
8 5 our $VERSION = '2.01'; # VERSION
9  
10  
11 5 ▶use DBI;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 5 has 'dsn' => ( is => 'ro', isa => 'Str', required => 1 );
14 5 has 'user' => ( is => 'ro', isa => 'Str', default => '' );
15 5 has 'password' => ( is => 'ro', isa => 'Str', default => '' );
16  
17 has 'handle' => ( is => 'rw', isa => 'DBI::db', lazy => 1,
18 default => sub {
19 4 ▶ my $self = shift;
Subroutine __ANON__: called CC=1 SCAR=0.0
20 4 return $self->_create_handle;
21 },
22 5 handles => [ 'disconnect' ],
23 );
24  
25 sub _create_handle {
26 4 ▶ my $self = shift;
Subroutine _create_handle: called CC=1 SCAR=0.0
27 4 my $handle = DBI->connect(
28 $self->dsn,
29 $self->user,
30 $self->password,
31 {
32 RaiseError => 1,
33 PrintError => 0,
34 AutoCommit => 1,
35 mysql_auto_reconnect => 1,
36 },
37 );
38 4 return $handle;
39 }
40  
41 sub reconnect {
42 0 ▶ my $self = shift;
Subroutine reconnect: not called CC=1 SCAR=6.9
Pod undocumented
43 0 $self->handle( $self->_create_handle );
44 }
45  
46 5 1;
47  
48 __END__
49  
50 =pod
51  
52 =encoding UTF-8
53  
54 =head1 NAME
55  
56 Mail::MtPolicyd::Connection::Sql - Connection pool sql connection object
57  
58 =head1 VERSION
59  
60 version 2.01
61  
62 =head1 SYNOPSIS
63  
64 <Connection db>
65 module = "Sql"
66 # see perldoc DBI for syntax of dsn connection string
67 dsn = "dbi:SQLite:dbname=/var/lib/mtpolicyd/mtpolicyd.sqlite"
68 # user = "mtpolicyd"
69 # user = "secret"
70 </Connection>
71  
72 =head1 PARAMETERS
73  
74 =over
75  
76 =item dsn (required)
77  
78 A perl DBI connection string.
79  
80 Examples:
81  
82 dbi:SQLite:dbname=/var/lib/mtpolicyd/mtpolicyd.sqlite
83 dbi:SQLite::memory:
84 DBI:mysql:database=test;host=localhost
85  
86 see L<DBI>
87  
88 =item user (default: '')
89  
90 A username if required for connection.
91  
92 =item password (default: '')
93  
94 A password if required for user/connection.
95  
96 =back
97  
98 =head1 AUTHOR
99  
100 Markus Benning <ich@markusbenning.de>
101  
102 =head1 COPYRIGHT AND LICENSE
103  
104 This software is Copyright (c) 2014 by Markus Benning <ich@markusbenning.de>.
105  
106 This is free software, licensed under:
107  
108 The GNU General Public License, Version 2, June 1991
109  
110 =cut
« MtPolicyd/Plugin/SetField.pm ↑ Summary MtPolicyd/AddressList.pm »