Skip to content

Commit d65ebba

Browse files
author
Noboru Saito
committed
Change of install method
Add JSON description
1 parent 4639d4a commit d65ebba

File tree

1 file changed

+51
-3
lines changed

1 file changed

+51
-3
lines changed

README.md

+51-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ The difference from these tools is that the syntax of PostgreSQL or MySQL can be
1313
## INSTALL
1414

1515
```
16-
go get -u github.com/noborus/trdsql
16+
go get -d github.com/noborus/trdsql
17+
cd $GOPATH/src/github.com/noborus/trdsql
18+
make
19+
make install
1720
```
1821
Or download binaries from the [releases](https://github.com/noborus/trdsql/releases) page(Linux/Windows/macOS).
1922

@@ -216,6 +219,50 @@ $ trdsql -ijson "SELECT * FROM sample.json"
216219
3,Apple,100
217220
```
218221

222+
JSON can contain structured types, but trdsql is stored as it is as JSON string.
223+
224+
sample2.json
225+
```JSON
226+
[
227+
{
228+
"id": 1,
229+
"name": "Drolet",
230+
"attribute": { "country": "Maldives", "color": "burlywood" }
231+
},
232+
{
233+
"id": 2,
234+
"name": "Shelly",
235+
"attribute": { "country": "Yemen", "color": "plum" }
236+
},
237+
{
238+
"id": 3,
239+
"name": "Tuck",
240+
"attribute": { "country": "Mayotte", "color": "antiquewhite" }
241+
}
242+
]
243+
```
244+
245+
```sh
246+
trdsql -ijson "SELECT * FROM sample2.json"
247+
```
248+
249+
```CSV
250+
1,Drolet,"{""color"":""burlywood"",""country"":""Maldives""}"
251+
2,Shelly,"{""color"":""plum"",""country"":""Yemen""}"
252+
3,Tuck,"{""color"":""antiquewhite"",""country"":""Mayotte""}"
253+
```
254+
255+
Please use SQL function.
256+
257+
```sh
258+
trdsql -ijson "SELECT id, name, JSON_EXTRACT(attribute,'$country'), JSON_EXTRACT(attribute,'$color') FROM sample2.json"
259+
```
260+
```CSV
261+
1,Drolet,Maldives,burlywood
262+
2,Shelly,Yemen,plum
263+
3,Tuck,Mayotte,antiquewhite
264+
```
265+
219266
Another json format. One record is JSON.
220267

221268
sample2.json
@@ -237,6 +284,7 @@ sample2.json
237284
}
238285
```
239286

287+
240288
-ojson is JSON Output.
241289

242290
```sh
@@ -292,7 +340,7 @@ trdsql -oraw -od "\t|\t" -db pdb "SELECT * FROM test.csv"
292340
```
293341

294342

295-
### ASCII Table & MarkDown (output only)
343+
### ASCII Table & MarkDown output
296344

297345
-oat is ASCII table output.
298346
It uses [tablewriter](https://github.com/olekukonko/tablewriter).
@@ -326,7 +374,7 @@ $ trdsql -omd "SELECT * FROM test.csv"
326374
| 3 | Apple |
327375
```
328376

329-
### Vertical format
377+
### Vertical format output
330378

331379
-ovf is Vertical format output("column name | value" vertically).
332380

0 commit comments

Comments
 (0)