NAME

fsql - Perform SQL queries against files in CSV/TSV/LTSV/JSON/YAML formats

VERSION

version 0.04

SYNOPSIS

fsql [OPTIONS] [ <QUERY> | --show-schema ]

DESCRIPTION

fsql lets you perform SQL queries against "flat" files of various formats. Each file will be regarded as a SQL table. The magic of all this is performed by DBD::CSV and SQL::Statement.

There must be at least one table specified (either with --add-csv, --add-tsv, --add-ltsv, --add-json, --add-yaml). If none of those options are specified, a JSON table is assumed in STDIN and table name stdin (if you want to change the table name, you can use --add-json -:somename.

OPTIONS

  • --add-csv=FILENAME[:TABLENAME]

    Add a table from a CSV file. If TABLENAME is not specified, it will be taken from FILENAME (e.g. with filename foo-bar.csv, table name will be foo_bar). FILENAME can be - to mean the standard input (the default table name will be stdin). Will croak if duplicate table name is detected.

    Table name must match regex /\A[A-Za-z_][A-Za-z_0-9]*\z/.

  • --add-tsv=FILENAME[:TABLENAME]

    Like --add-csv, but will load file as TSV (tab-separated value).

  • --add-ltsv=FILENAME[:TABLENAME]

    Like --add-csv, but will load file as LTSV (labeled tab separated value, see Text::LTSV). Names of columns will be taken from the first row.

  • --add-json=FILENAME[:TABLENAME]

    Like --add-csv, but will load file as JSON.

    Data can be array, or array of arrays, or array of hashes, or an enveloped response (see Rinci::function), so it is suitable to accept piped output of Perinci::CmdLine-based programs.

  • --add-yaml=FILENAME[:TABLENAME]

    Like --add-json, but will load file as YAML.

  • --format=FORMAT (default: text)

    Set output format. This will be passed to Perinci::Result::Format's format().

  • --json

    Equivalent to --format json.

  • --yaml

    Equivalent to --format yaml.

  • --show-schema

    Instead of running a query, show schema instead. This is useful for debugging.

EXIT CODES

0 on success.

255 on I/O or SQL error.

99 on command-line options or input data error.

FAQ

TODO

Allow customized CSV separator and quoting.

HOMEPAGE

Please visit the project's homepage at https://metacpan.org/release/App-fsql.

SOURCE

Source repository is at https://github.com/sharyanto/perl-App-fsql.

BUGS

Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=App-fsql

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.

AUTHOR

Steven Haryanto <stevenharyanto@gmail.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2014 by Steven Haryanto.

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