| 1 | package Eve::PgSqlConnection; | ||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||
| 3 | 9 | ▶ | use parent qw(Eve::Class); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||
| 5 | 9 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 6 | 9 | ▶ | use warnings; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||
| 8 | 9 | ▶ | use DBI; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||
| 10 | =head1 NAME | ||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||
| 12 | B<Eve::PgSqlConnection> - a class for PostgreSQL connection. | ||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||
| 14 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||
| 16 | my $pgsql_connection = Eve::PgSqlConnection->new( | ||||||||||||||||||||||||||||||||
| 17 | host => 'localhost', port => '5432', database => 'somedb', | ||||||||||||||||||||||||||||||||
| 18 | user => 'someuser', password => 'somepassword', schema => 'someschema'); | ||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||
| 20 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||
| 22 | B<Eve::PgSqlConnection> is an adapter class for PostgreSQL | ||||||||||||||||||||||||||||||||
| 23 | connection. It adapts B<DBI>'s database handle with B<DBD::Pg> driver | ||||||||||||||||||||||||||||||||
| 24 | and encapsulates connection establishing mechanisms and confuguring | ||||||||||||||||||||||||||||||||
| 25 | practices. | ||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||
| 27 | =head3 Attributes | ||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||
| 29 | =over 4 | ||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||
| 31 | =item C<dbh> | ||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||
| 33 | a service attribute containing a data base handle (not for regular | ||||||||||||||||||||||||||||||||
| 34 | use). | ||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||
| 36 | =back | ||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||
| 38 | =head3 Constructor arguments | ||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||
| 40 | =over 4 | ||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||
| 42 | =item C<host> | ||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||
| 44 | =item C<port> | ||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||
| 46 | =item C<database> | ||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||
| 48 | =item C<user> | ||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||
| 50 | =item C<password> | ||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||
| 52 | =item C<schema> | ||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||
| 54 | =back | ||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||
| 56 | For default argument values see the B<DBD::Pg> documentation. | ||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||
| 58 | =head1 METHODS | ||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||
| 60 | =head2 B<init()> | ||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||
| 62 | =cut | ||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||
| 64 | 0 | ▶ | sub init { | ||||||||||||||||||||||||||||||
|
Subroutine
init: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 65 | 0 | my ($self, %arg_hash) = @_; | |||||||||||||||||||||||||||||||
| 66 | 0 | Eve::Support::arguments( | |||||||||||||||||||||||||||||||
| 67 | \%arg_hash, | ||||||||||||||||||||||||||||||||
| 68 | my ($host, $port, $database, $user, $password, $schema) = | ||||||||||||||||||||||||||||||||
| 69 | (\undef) x 6); | ||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||
| 71 | 0 | ▶ | $self->{'dbh'} = DBI->connect( | ||||||||||||||||||||||||||||||
|
Condition0%0/6
$database || ''
$host || ''
$port || ''
MC/DC0%0/1
$database || ''
$database
MC/DC0%0/1
$host || ''
$host
MC/DC0%0/1
$port || ''
$port
Truth table0%0/2
A
A= $database
Truth table0%0/2
A
A= $host
Truth table0%0/2
A
A= $port
| |||||||||||||||||||||||||||||||||
| 72 | 'dbi:Pg:dbname='.($database or '').';host='.($host or ''). | ||||||||||||||||||||||||||||||||
| 73 | ';port='.($port or ''), $user, $password, | ||||||||||||||||||||||||||||||||
| 74 | { | ||||||||||||||||||||||||||||||||
| 75 | RaiseError => 1, ShowErrorStatement => 1, AutoCommit => 1, | ||||||||||||||||||||||||||||||||
| 76 | pg_server_prepare => 1, pg_enable_utf8 => 1 | ||||||||||||||||||||||||||||||||
| 77 | }); | ||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||
| 79 | 0 | return; | |||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||
| 82 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||
| 84 | =over 4 | ||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||
| 86 | =item L<DBI> | ||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||
| 88 | =item L<DBD::Pg> | ||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||
| 90 | =item L<Eve::Class> | ||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||
| 92 | =back | ||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||
| 94 | =head1 LICENSE AND COPYRIGHT | ||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||
| 96 | Copyright 2012 Igor Zinovyev. | ||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||
| 98 | This program is free software; you can redistribute it and/or modify it | ||||||||||||||||||||||||||||||||
| 99 | under the terms of either: the GNU General Public License as published | ||||||||||||||||||||||||||||||||
| 100 | by the Free Software Foundation; or the Artistic License. | ||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||
| 102 | See http://dev.perl.org/licenses/ for more information. | ||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||
| 105 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||
| 107 | =over 4 | ||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||
| 109 | =item L<Sergey Konoplev|mailto:gray.ru@gmail.com> | ||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||
| 111 | =back | ||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||
| 113 | =cut | ||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||
| 115 | 9 | 1; | |||||||||||||||||||||||||||||||