| 1 | # ABSTRACT SQL Simple Operations Commands | ||
| 2 | # | ||
| 3 | ## LICENSE AND COPYRIGHT | ||
| 4 | # | ||
| 5 | ## Copyright (C) Carlos Celso | ||
| 6 | # | ||
| 7 | ## This program is free software: you can redistribute it and/or modify | ||
| 8 | ## it under the terms of the GNU General Public License as published by | ||
| 9 | ## the Free Software Foundation, either version 3 of the License, or | ||
| 10 | ## (at your option) any later version. | ||
| 11 | # | ||
| 12 | ## This program is distributed in the hope that it will be useful, | ||
| 13 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | ## GNU General Public License for more details. | ||
| 16 | # | ||
| 17 | ## You should have received a copy of the GNU General Public License | ||
| 18 | ## along with this program. If not, see L<http://www.gnu.org/licenses/>. | ||
| 19 | # | ||
| 20 | |||
| 21 | package SQL::SimpleOps::DBI::PG; | ||
| 22 | |||
| 23 | use 5.006001; | ||
| 24 | use strict; | ||
| 25 | use warnings; | ||
| 26 | use Exporter; | ||
| 27 | |||
| 28 | our @ISA = qw ( Exporter ); | ||
| 29 | |||
| 30 | our @EXPORT = qw(new Open $VERSION); | ||
| 31 | |||
| 32 | our $VERSION = "2026.129.1"; | ||
| 33 | |||
| 34 | our @EXPORT_OK = @EXPORT; | ||
| 35 | |||
| 36 | our %EXPORT_TAGS = ( all => [@EXPORT_OK] ); | ||
| 37 | 1; | ||
| 38 | |||
| 39 | ############################################################################### | ||
| 40 | ## plugin initialization | ||
| 41 | |||
| 42 | sub new() | ||
| 43 | { | ||
| 44 | my $class = shift; $class = ref($class) || $class || 'SQL::SimpleOps::DBI::PG'; | ||
| 45 | my $self = {@_}; | ||
| 46 | |||
| 47 | $self->{sql_simple}->{init}{plugin_id} = "PG"; | ||
| 48 | $self->{sql_simple}->{init}{schema} = 1; | ||
| 49 | $self->{sql_simple}->{init}{test_server} = 1; | ||
| 50 | $self->{sql_simple}->{init}{alias_with_as} = 1; | ||
| 51 | |||
| 52 | bless($self,$class); | ||
| 53 | } | ||
| 54 | |||
| 55 | ############################################################################### | ||
| 56 | ## initialize here the dsname by: | ||
| 57 | # | ||
| 58 | ## All methods can be executed using the format: | ||
| 59 | # $self_sql_simple->[method_name](); | ||
| 60 | # | ||
| 61 | ## return codes: | ||
| 62 | ## rc=0 ok, continue | ||
| 63 | ## rc<1 syntax, abort | ||
| 64 | ## rc=1 error, abort | ||
| 65 | ## rc=2 ok, ignore caller | ||
| 66 | |||
| 67 | sub Open() | ||
| 68 | { | ||
| 69 | my $self = shift; | ||
| 70 | my $argv = shift; | ||
| 71 | |||
| 72 | my @options; | ||
| 73 | push(@options,"dbname=".$self->{sql_simple}->{argv}{db}) if (defined($self->{sql_simple}->{argv}{db}) && $self->{sql_simple}->{argv}{db} ne ""); | ||
| 74 | push(@options,"host=".$self->{sql_simple}->{argv}{server}) if (defined($self->{sql_simple}->{argv}{server}) && $self->{sql_simple}->{argv}{server} ne ""); | ||
| 75 | push(@options,$self->{sql_simple}->{argv}{port}) if (defined($self->{sql_simple}->{argv}{port}) && $self->{sql_simple}->{argv}{port} ne ""); | ||
| 76 | |||
| 77 | ## sets the dsnam here | ||
| 78 | $self->{sql_simple}->{argv}{dsname} = "DBI:Pg:".join(';',@options); | ||
| 79 | return 0; | ||
| 80 | } | ||
| 81 | |||
| 82 | __END__ |