NAME

dbload.pl - Perl routine to load delimited records into a database


SYNOPSIS

    $ dbload.pl --control=file.name \
                --table=db_table \
                --dbconnect="dbi:Pg:dbname=my_db" \
                --delimiter=":" \
                data.file...


DESCRIPTION

dbload.pl loads a database table from delimited fields in the input files.

The first line of each input data file should contain a delimited list of field names.

Options may be specified on the command line or in a control file. The control file can also contain field name mappings if the field names in the data file do not match the field names in the database.

The program first parses any command line options. A control file is then parsed if one was specified. Any remaining arguments on the command line are then read as data files.

The first line of each data file is translated as a delimited list of field names. Each name is translated through the field mappings specified in the control file. The resulting list of field names is used to build an SQL INSERT statement. The remaining lines of the data file are then read, split into fields and passed to the database by executing the statement.


COMMAND LINE OPTIONS

--control=<file name>

Reads the specified file as a control file.

--dbconnect=<string>

Uses the specified string to connect to the database. For more information on the format of this string, see the help for DBI module and the DBD backend for your database. The default connect string is ``dbi:Pg:''.

--dbuser=<string>
--dbpass=<string>

Specifies authorization information for the database connection.

--delimiter=char

Uses the specified character as the field delimiter. If not specified, fields are delimited by tab characters.

--table=<table name>

Loads data into the specified table. The table name must be specified either on the command line or in a control file.


CONTROL FILE OPTIONS

dbconnect = string

Uses the specified string to connect to the database. Whitespace following the equals sign is removed and any remaining text on the line is used as the connect string.

delimiter = "c"

Specifies 'c' as the field delimiter character. The default is a tab.

dbuser = <string>
dbpass = <string>

Specifies authorization information for the database connection.

table = table_name

Specifies the name of the database table to load.

file_field -> table_field

Enters a field name mapping. The column named 'file_field' will be loaded into the database column named 'table_field'.


AUTHOR

Thomas Pfau <pfau@eclipse.net>


COPYRIGHT AND DISCLAIMER

This program is Copyright 1999 by Thomas Pfau <pfau@eclipse.net>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

If you do not have a copy of the GNU General Public License write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.