Name
Dump AltSQL Plugin
Synopsis
Usage:
.
dump
<file>.[csv|html|json|pl|pm|sql|xls|xml|yaml|yml] <query>;
Description
This plugin will allow you to dump out results from a sql query into one of many data formats.
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:
id | name |
---|---|
1 | Moo |
2 | Pie |
3 | Cow |
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>
<field name=
"id"
>2</field>
<field name=
"name"
>Pie</field>
</row>
<row>
<field name=
"id"
>3</field>
<field name=
"name"
>Cow</field>
</row>
</table>
YAML:
.
dump
out.[yaml|yml]
select
* from users;
out.[yaml|yml]:
---
- id: 1
name: Moo
- id: 2
name: Pie
- id: 3
name: Cow