GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
SPOPS::Import::DBI::Data(3) User Contributed Perl Documentation SPOPS::Import::DBI::Data(3)

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

 #!/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;
}

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

data_from_file( $filename )

Runs "raw_data_from_file( $filename )" from SPOPS::Import to read a serialized Perl data structure from $filename, then sends the arrayref to "assign_raw_data()" and returns the result.

data_from_fh( $filehandle )

Runs "raw_data_from_fh( $filename )" from SPOPS::Import to read a serialized Perl data structure from $filehandle, then sends the arrayref to "assign_raw_data()" and returns the result.

assign_raw_data( \@( \%metadata, @data ) )

Assigns the data 'table' and 'fields' from "\%metadata" to the import object, then the remainder of the data to the 'data' property.

The additional metadata is stored under the 'extra_metadata' property of the import object.

None known.

Nothing known.

Copyright (c) 2001-2004 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.

Chris Winters <chris@cwinters.com>
2004-06-02 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.