dbiloader - A tiny script to load CSV/TSV contents into a database table via DBI
version v0.0.2
dbiloader -h
-h
dbiloader [-c] [-t <separator>] [-u <username>] [-p <password>] <connection> <table> [<schema>] [<files>...]
-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
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.
Show POD help.
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.
split
Clear the specified table before contents loading.
Specify username.
Specify password.
Specify DBI connection string.
Specify table name.
Specify table schema optionally. This is appended to 'CREATE TABLE <table>' SQL. Expected to be as \(.*\).
\(.*\)
Specify CSV/TSV files. If omitted or '-' is specified, STDIN is used.
Yasutaka ATARASHI <yakex@cpan.org>
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.
To install App::DBI::Loader, copy and paste the appropriate command in to your terminal.
cpanm
cpanm App::DBI::Loader
CPAN shell
perl -MCPAN -e shell install App::DBI::Loader
For more information on module installation, please visit the detailed CPAN module installation guide.