-
-
Notifications
You must be signed in to change notification settings - Fork 76
Home
Noboru Saito edited this page Oct 19, 2019
·
8 revisions
Welcome to the trdsql wiki!
Execute SQL to CSV, TSV, LTSV, JSON, and TBLN.
Ignore the space before and after the delimiter. So, it can be used in the shaping of the output of the command.
$ ps |trdsql -oat -ih -id " " "SELECT * FROM -"
+-------+-------+----------+--------+
| PID | TTY | TIME | CMD |
+-------+-------+----------+--------+
| 11704 | pts/2 | 00:00:00 | ps |
| 11705 | pts/2 | 00:00:00 | trdsql |
| 23171 | pts/2 | 00:00:27 | zsh |
+-------+-------+----------+--------+
You can give another name by AS. If you want to change the output name.
trdsql -ojson "SELECT c1 as id ,c2 as name FROM test.csv"
[
{
"id": "1",
"name": "Orange"
},
{
"id": "2",
"name": "Melon"
},
{
"id": "3",
"name": "Apple"
}
]
When you want to name a table column. Add item name to CSV without header line.
$ cat <(echo id,name) test.csv|trdsql -ojson -ih "SELECT * FROM -"
[
{
"id": "1",
"name": "Orange"
},
{
"id": "2",
"name": "Melon"
},
{
"id": "3",
"name": "Apple"
}
]