Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

executable file 62 lines (38 sloc) 1.392 kb
#!/usr/bin/perl
use App::PipeFilter::MysqlToJson;
exit App::PipeFilter::MysqlToJson->new_with_options()->run();
__END__
=pod
=head1 NAME
mysql2json - convert mysql -B output to JSON object streams
=head1 SYNOPSIS
mysql -B -u user -password -h 10.0.0.5 database \
-e 'select crontab_id, task_id from crontab' | \
mysql2json | jsort -k task_id -rn | head -5
=head1 DESCRIPTION
mysql2json(1) reads mysql(1) batch output and writes JSON objects, one
per line, corresponding to each database row.
The SYNOPSIS example produces something like this:
{"crontab_id":"102","task_id":"701"}
{"crontab_id":"101","task_id":"700"}
{"crontab_id":"100","task_id":"650"}
{"crontab_id":"8","task_id":"599"}
{"crontab_id":"14","task_id":"38"}
=head1 SEE ALSO
You may read this utility's implementation in its entirety at
perldoc -m mysql2json
L<App::PipeFilter::MysqlToJson> implements this utility.
L<App::PipeFilter> has top-level documentation including a table of
contents for all the libraries and utilities included in the project.
=head1 BUGS
L<https://rt.cpan.org/Public/Dist/Display.html?Name=App-PipeFilter>
=head1 REPOSITORY
L<https://github.com/rcaputo/app-pipefilter>
=head1 COPYRIGHT AND LICENSE
mysql2json
is Copyright 2011 by Rocco Caputo.
All rights are reserved.
mysql2json
is released under the same terms as Perl itself.
=cut
# vim: ts=2 sw=2 expandtab
Jump to Line
Something went wrong with that request. Please try again.