line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package SQL::Exec::SQLite; |
2
|
16
|
|
|
16
|
|
18604
|
use strict; |
|
16
|
|
|
|
|
27
|
|
|
16
|
|
|
|
|
517
|
|
3
|
16
|
|
|
16
|
|
78
|
use warnings; |
|
16
|
|
|
|
|
25
|
|
|
16
|
|
|
|
|
408
|
|
4
|
16
|
|
|
16
|
|
77
|
use Exporter 'import'; |
|
16
|
|
|
|
|
31
|
|
|
16
|
|
|
|
|
642
|
|
5
|
16
|
|
|
16
|
|
14877
|
use SQL::Exec '/.*/', '!connect', '!test_driver'; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our @ISA = ('SQL::Exec'); |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our @EXPORT_OK = ('test_driver', @SQL::Exec::EXPORT_OK); |
10
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( all => \@EXPORT_OK ); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub test_driver { |
13
|
|
|
|
|
|
|
return SQL::Exec::test_driver('SQLite'); |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub build_connect_args { |
17
|
|
|
|
|
|
|
my ($class, $file, @opt) = @_; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
return ("dbi:SQLite:dbname=$file", undef, undef, @opt); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub get_default_connect_option { |
23
|
|
|
|
|
|
|
my $c = shift; |
24
|
|
|
|
|
|
|
return ( |
25
|
|
|
|
|
|
|
$c->SUPER::get_default_connect_option(), |
26
|
|
|
|
|
|
|
sqlite_see_if_its_a_number => 1, |
27
|
|
|
|
|
|
|
sqlite_use_immediate_transaction => 1, |
28
|
|
|
|
|
|
|
Callbacks => { connected => sub { $_[0]->do("PRAGMA foreign_keys = ON"); return } }, |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub connect { |
33
|
|
|
|
|
|
|
my $c = &SQL::Exec::check_options; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
if (!test_driver()) { |
36
|
|
|
|
|
|
|
$c->error("You must install the DBD::SQLitee Perl module"); |
37
|
|
|
|
|
|
|
return; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
if (not $c->isa(__PACKAGE__)) { |
41
|
|
|
|
|
|
|
bless $c, __PACKAGE__; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
return $c->__connect($c->build_connect_args(@_)); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
1; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=encoding utf-8 |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 NAME |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
SQL::Exec::SQLite - Specific support for the DBD::SQLite DBI driver in SQL::Exec |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 SYNOPSIS |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
use SQL::Exec::SQLite; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
SQL::Exec::SQLite::connect('/tmp/my.db'); |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 DESCRIPTION |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
The C package is an extension of the L|SQL::Exec> |
65
|
|
|
|
|
|
|
package. This mean that in an OO context C is a sub-classe |
66
|
|
|
|
|
|
|
of C (so all methods of the later can be used in the former). Also, in |
67
|
|
|
|
|
|
|
a functionnal context, all functions of C can be accessed through |
68
|
|
|
|
|
|
|
C. |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 CONSTRUCTOR |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
my $c = SQL::Exec::SQLite->new(file); |
73
|
|
|
|
|
|
|
my $c = SQL::Exec::SQLite->new(file, opts); |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
The C constructor of this package takes only a single argument which is the |
76
|
|
|
|
|
|
|
name of the file to use as a database. The constructor can also takes an optionnal |
77
|
|
|
|
|
|
|
argument wich contains option to apply to the created database handle, either as |
78
|
|
|
|
|
|
|
a hash or as a reference to a hash. |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
The database file is created automatically if it does not already exist. Also |
81
|
|
|
|
|
|
|
you may use the special file name C<':memory'> to use a in-memory database. In |
82
|
|
|
|
|
|
|
that case, all your data will be destroyed when you close the database handle. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 FUNCTIONS |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
The function described here are either functions specific to this database driver |
87
|
|
|
|
|
|
|
or special version of a C function adapted for the database driver. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
However, all the function of C are accessible in this package, either |
90
|
|
|
|
|
|
|
with the object oriented interface or with the functionnal one. This package can |
91
|
|
|
|
|
|
|
also exports all the function of the C package and the C<:all> tag |
92
|
|
|
|
|
|
|
contains all exportable functions from both C and this package. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head2 connect |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
connect(file); |
97
|
|
|
|
|
|
|
$c->connect(file); |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
As the L|SQL::Exec/"connect"> function in C this function |
100
|
|
|
|
|
|
|
will either connect the default handle of the library or connect a specific |
101
|
|
|
|
|
|
|
handle that is already created. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
This function takes the same arguments as the C constructor, except that |
104
|
|
|
|
|
|
|
the optionnal options hash must be given as a hash reference and that it applies |
105
|
|
|
|
|
|
|
only for the duration of the call (this is the same as the |
106
|
|
|
|
|
|
|
L|SQL::Exec/"connect"> function in C). |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head2 test_driver |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
my $t = test_driver(); |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
This function returns a boolean value indicating if the C database |
113
|
|
|
|
|
|
|
driver is installed. |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 BUGS |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or |
118
|
|
|
|
|
|
|
through the web interface at L. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 SEE ALSO |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
For the main documentation of this module ond for a list of all available functions, |
123
|
|
|
|
|
|
|
please check the C> module. |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
For details about the SQLite database driver, you should check the documentation for |
126
|
|
|
|
|
|
|
C> |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
Copyright 2013 © Mathias Kende. All rights reserved. |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or |
133
|
|
|
|
|
|
|
modify it under the same terms as Perl itself. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=cut |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
|