NAME

dbiloader - A tiny script to load CSV/TSV contents into a database table via DBI

VERSION

version v0.0.2

SYNOPSIS

dbiloader -h

dbiloader [-c] [-t <separator>] [-u <username>] [-p <password>] <connection> <table> [<schema>] [<files>...]

# Read TSV and load into mytable in SQLite database t.db
dbiloader -t '\t' dbi:SQLite:t.db mytable data.txt

# Clear mytable, read CSV (default), and load into mytable in SQLite database t.db
dbiloader -c dbi:SQLite:t.db mytable data.txt

# Drop mytalbe if exists, create mytable, read CSV (default), and load into mytable in SQLite database t.db
dbiloader dbi:SQLite:t.db mytable '(key INTEGER PRIMARY KEY, value INTEGER)' data.txt

DESCRIPTION

TSV/CSV is a friend of text processing. RDBMS/SQL is a friend of analyzing data. I quite often create a working table from a TSV/CSV file. This tiny script is created for the purpose. By this script, CSV/TSV contents are loaded into a database table via DBI.

OPTIONS

-h

Show POD help.

-t <separator>

Specify field separator. Defaults to ',' (a comma). This is passed to split. NOTE that field separation is currently done by just a split. Thus, quoting is not correctly handled.

-c

Clear the specified table before contents loading.

-u <username>

Specify username.

-p <password>

Specify password.

<connection>

Specify DBI connection string.

<table>

Specify table name.

<schema>

Specify table schema optionally. This is appended to 'CREATE TABLE <table>' SQL. Expected to be as \(.*\).

<files>...

Specify CSV/TSV files. If omitted or '-' is specified, STDIN is used.

AUTHOR

Yasutaka ATARASHI <yakex@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2013 by Yasutaka ATARASHI.

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