App-AltSQL
view release on metacpan or search on metacpan
lib/App/AltSQL/Plugin/Dump.pm view on Meta::CPAN
package App::AltSQL::Plugin::Dump;
use Moose::Role;
use Moose::Util qw( apply_all_roles );
use App::AltSQL::Plugin::Dump::Format;
=head1 Name
Dump AltSQL Plugin
=head1 Synopsis
Usage:
.dump <file>.[csv|html|json|pl|pm|sql|xls|xml|yaml|yml] <query>;
=head1 Description
This plugin will allow you to dump out results from
a sql query into one of many data formats.
=head1 Examples
Given:
CREATE TABLE `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(32) NOT NULL,
PRIMARY KEY (`id`)
);
CSV:
.dump out.csv select * from users;
out.csv:
"id","name"
"1","Moo"
"2","Pie"
"3","Cow"
HTML:
.dump out.html select * from users;
out.html:
=begin html
<style>table{margin: 1em 1em 1em 2em;background: whitesmoke;border-collapse: collapse;}table th, table td{border: 1px gainsboro solid;padding: 0.2em;}table th{background: gainsboro;text-align: left;}</style><table><tr><th>id</th><th>name</th></tr><tr...
=end html
JSON:
.dump out.json select * from users;
out.json:
[{"name":"Moo","id":"1"},{"name":"Pie","id":"2"},{"name":"Cow","id":"3"}]
PERL:
.dump out.[pl|pm] select * from users;
out.[pl|pm]:
$VAR1 = [
{
'id' => '1',
'name' => 'Moo'
},
{
'id' => '2',
'name' => 'Pie'
},
{
'id' => '3',
'name' => 'Cow'
},
];
SQL:
.dump out.sql select * from users;
out.sql:
INSERT INTO table (`id`,`name`) VALUES('1','Moo'),('2','Pie'),('3','Cow');
XLS:
.dump out.xls select * from users;
out.xls:
You just get a excel spreadsheet...
XML:
.dump out.xml select * from users;
out.xml:
<table>
<row>
<field name="id">1</field>
<field name="name">Moo</field>
</row>
<row>
( run in 0.645 second using v1.01-cache-2.11-cpan-0d23b851a93 )