File Coverage

blib/lib/SQL/SimpleOps/DBI/SQLite.pm
Criterion Covered Total %
statement 25 27 92.5
branch 2 4 50.0
condition 3 8 37.5
subroutine 6 6 100.0
pod 0 2 0.0
total 36 47 76.6


line stmt bran cond sub pod time code
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.
19             #
20             package SQL::SimpleOps::DBI::SQLite;
21              
22 2     2   38 use 5.006001;
  2         7  
23 2     2   10 use strict;
  2         4  
  2         49  
24 2     2   11 use warnings;
  2         4  
  2         45  
25 2     2   11 use Exporter;
  2         4  
  2         784  
26              
27             our @ISA = qw ( Exporter );
28              
29             our @EXPORT = qw(new Open $VERSION);
30              
31             our $VERSION = "2023.274.1";
32              
33             our @EXPORT_OK = @EXPORT;
34              
35             our %EXPORT_TAGS = ( all => [@EXPORT_OK] );
36             1;
37              
38             ###############################################################################
39             ## plugin initialization
40              
41             sub new()
42             {
43 2   50 2 0 5 my $class = shift; $class = ref($class) || $class || 'SQL::SimpleOps::DBI::SQLite';
  2         13  
44 2         4 my $self = {@_};
45              
46 2 50 33     9 if ($self->{sql_simple}->{argv}{db} eq "" && $self->{sql_simple}->{argv}{dbfile} eq "")
47             {
48 0         0 $self->{sql_simple}->setMessage($self,"new",-1,"001");
49 0         0 return undef;
50             }
51 2         9 $self->{sql_simple}->{init}{plugin_id} = "SQLite";
52 2         4 $self->{sql_simple}->{init}{schema} = 0;
53 2         4 $self->{sql_simple}->{init}{test_server} = 0;
54 2         2 $self->{sql_simple}->{init}{alias_with_as} = 0;
55              
56 2         8 bless($self,$class);
57             }
58              
59             ###############################################################################
60             ## initialize here the dsname by:
61             #
62             ## All methods can be executed using the format:
63             # $self_sql_simple->[method_name]();
64             #
65             ## return codes:
66             ## rc=0 ok, continue
67             ## rc<1 syntax, abort
68             ## rc=1 error, abort
69             ## rc=2 ok, ignore caller
70              
71             sub Open()
72             {
73 1     1 0 2 my $self = shift;
74 1         3 my $argv = shift;
75              
76             ## sets the dsnam here
77 1 50 33     50 $self->{sql_simple}->{argv}{dbfile} = $self->{sql_simple}->{argv}{db}.".db" if (!defined($self->{sql_simple}->{argv}{dbfile}) || $self->{sql_simple}->{argv}{dbfile} eq "");
78 1         5 $self->{sql_simple}->{argv}{dsname} = "DBI:SQLite:dbname=$self->{sql_simple}->{argv}{dbfile}";
79              
80 1         7 return 0;
81             }
82              
83             __END__