9447505a56795f6536bd90f9865cd9736db1fc3f
[spider.git] / perl / DXSql / SQLite.pm
1 #
2 # Module for SQLite DXSql variants
3 #
4 # Stuff like table creates and (later) alters
5 #
6 # $Id$
7 #
8 # Copyright (c) 2005 Dirk Koopman G1TLH
9 #
10
11 package DXSql::SQLite;
12
13 use DXDebug;
14
15 use vars qw($VERSION $BRANCH @ISA);
16 $VERSION = sprintf( "%d.%03d", q$Revision$ =~ /(\d+)\.(\d+)/ );
17 $BRANCH = sprintf( "%d.%03d", q$Revision$ =~ /\d+\.\d+\.(\d+)\.(\d+)/  || (0,0));
18 $main::build += $VERSION;
19 $main::branch += $BRANCH;
20
21 @ISA = qw{DXSql};
22
23 sub show_tables
24 {
25         my $self = shift;
26         my $s = q(SELECT name FROM sqlite_master WHERE type='table' ORDER BY name);
27         my $sth = $self->prepare($s);
28         $sth->execute;
29         my @out;
30         push @out, $sth->fetchrow_array;
31         $sth->finish;
32         return @out;
33 }
34
35 sub spot_create_table
36 {
37         my $self = shift;
38         my $s = q{create table spot (
39 rowid integer primary key,
40 freq real not null,
41 spotcall text not null,
42 time int not null,
43 comment text,
44 spotter text not null,
45 spotdxcc int,
46 spotterdxcc int,
47 origin text,
48 spotitu int,
49 spotcq int,
50 spotteritu int,
51 spottercq int,
52 spotstate text,
53 spotterstate text
54 )};
55         $self->do($s);
56 }
57
58 sub spot_add_indexes
59 {
60         my $self = shift;
61         $self->do('create index spot_ix1 on spot(time desc)');
62         dbg('adding spot index ix1');
63         $self->do('create index spot_ix2 on spot(spotcall asc)');
64         dbg('adding spot index ix2');
65 }
66
67
68 1;