The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

SPOPS::Import::DBI::Data - Import raw data to a DBI table

SYNOPSIS

 #!/usr/bin/perl

 use strict;
 use DBI;
 use SPOPS::Import;

 {
     my $dbh = DBI->connect( 'DBI:Pg:dbname=test' );
     $dbh->{RaiseError} = 1;

     my $table_sql = qq/
       CREATE TABLE import ( import_id SERIAL,
                             name varchar(50),
                             bad int,
                             good int,
                             disco int ) /;
     $dbh->do( $table_sql );

     my $importer = SPOPS::Import->new( 'dbdata' );
     $importer->db( $dbh );
     $importer->table( 'import' );
     $importer->fields( [ 'name', 'bad', 'good', 'disco' ] );
     $importer->data( [ [ 'Saturday Night Fever', 5, 10, 15 ],
                        [ 'Grease', 12, 5, 2 ],
                        [ "You Can't Stop the Music", 15, 0, 12 ] ] );
     my $status = $importer->run;
     foreach my $entry ( @{ $status } ) {
         if ( $entry->[0] ) { print "$entry->[1][0]: OK\n" }
         else               { print "$entry->[1][0]: FAIL ($entry->[2])\n" }
     }

     $dbh->do( 'DROP TABLE import' );
     $dbh->do( 'DROP SEQUENCE import_import_id_seq' );
     $dbh->disconnect;
}

DESCRIPTION

Import raw (non-object) data to a DBI table.

METHODS

BUGS

None known.

TO DO

Nothing known.

SEE ALSO

COPYRIGHT

Copyright (c) 2001-2002 intes.net, inc.. All rights reserved.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

AUTHORS

Chris Winters <chris@cwinters.com>