/[Frey]/trunk/lib/Frey/SQL.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /trunk/lib/Frey/SQL.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 414 - (hide annotations)
Tue Nov 18 14:15:45 2008 UTC (15 years, 5 months ago) by dpavlin
File size: 914 byte(s)
decrease output without debug
1 dpavlin 370 package Frey::SQL;
2     use Moose;
3 dpavlin 414 extends 'Frey';
4 dpavlin 370
5     use MooseX::Types::Moose qw(Str Int ArrayRef);
6     use MooseX::Types::Structured qw/Dict/;
7    
8     use DBI;
9     use Data::Dump qw/dump/;
10    
11     has 'query' => (
12     is => 'rw',
13     isa => 'Str',
14     required => 1,
15 dpavlin 371 default => 'select * from sponge',
16 dpavlin 374 documentation => 'SQL query to filter data',
17 dpavlin 370 );
18    
19     has table => (
20     is => 'rw',
21     isa => 'Str',
22     required => 1,
23     default => 'sponge',
24 dpavlin 374 documentation => 'Name of table to create from sponge data',
25 dpavlin 370 );
26    
27     has 'sponge' => (
28     is => 'rw',
29     isa => Dict[
30     rows => ArrayRef[ArrayRef],
31     NAME => ArrayRef[Str],
32     ],
33     required => 1,
34     );
35    
36     sub data {
37     my ($self) = @_;
38    
39     my $dbh=DBI->connect('dbi:AnyData(RaiseError=>1):');
40    
41     my $data = $self->sponge->{rows};
42     unshift @$data, $self->sponge->{NAME};
43    
44 dpavlin 414 warn "# data = ",dump( $data ) if $self->debug;
45 dpavlin 370
46     $dbh->func( $self->table, 'ARRAY', $data, 'ad_import' );
47    
48     return $dbh->selectall_arrayref( $self->query );
49     }
50    
51     1;

  ViewVC Help
Powered by ViewVC 1.1.26