Skip to content

Commit

Permalink
fix trdsql doc
Browse files Browse the repository at this point in the history
  • Loading branch information
noborus committed Apr 29, 2024
1 parent cd2bb17 commit 0049d1d
Show file tree
Hide file tree
Showing 12 changed files with 26 additions and 21 deletions.
2 changes: 1 addition & 1 deletion content/_index.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ archetype: "home"
weight: 1
---

## <i class="fas fa-hammer"></i> Products
## [<i class="fas fa-hammer"></i> Products](https://github.com/noborus/)

---

Expand Down
2 changes: 1 addition & 1 deletion content/_index.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ archetype: "home"
weight: 1
---

## <i class="fas fa-hammer"></i> 作ったもの
## [<i class="fas fa-hammer"></i> 作ったもの](https://github.com/noborus/)

---

Expand Down
8 changes: 4 additions & 4 deletions content/trdsql/02_convert.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,11 @@ trdsql -icsv -ih -ovf "SELECT * FROM header.csv"
| Format | input | Output | Note |
|:-----|:----:|:---:|:-------|
| CSV | OK | OK | TSV etc. correspond to options |
| LTSV | OK | OK | [Ltsv.org] (http://ltsv.org) |
| JSON | OK | OK | [www.json.org] (www.json.org) |
| LTSV | OK | OK | [Ltsv.org](http://ltsv.org) |
| JSON | OK | OK | [www.json.org](www.json.org) |
| JSONL | OK | OK | Input is possible with JSON |
| YAML | OK | OK | [yaml.org] (http://yaml.org) |
| TBLN | OK | OK | [tbln.dev] (https://tbln.dev) |
| YAML | OK | OK | [yaml.org](http://yaml.org) |
| TBLN | OK | OK | [tbln.dev](https://tbln.dev) |
| RAW | NG | OK | Output as it is (do not process escape) |
| MD | NG | OK | Markdown table |
| At | NG| OK | ASCII table |
Expand Down
6 changes: 3 additions & 3 deletions content/trdsql/02_convert.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ CSV(-icsv)からLTSV(-oltsv)への変換は以下のようにします。
trdsql -icsv -oltsv "SELECT * FROM ファイル名"
```


### CSV header

CSVファイルはヘッダーに列名がついている場合 -ih でヘッダーを解釈して列名として使用できます。
Expand Down Expand Up @@ -143,7 +142,8 @@ trdsql -ijson -ocsv "SELECT * FROM test.json"
```console
trdsql -icsv -ih -ovf "SELECT * FROM header.csv"
```
```

```md
| id | name |
|----|--------|
| 1 | Orange |
Expand Down Expand Up @@ -177,7 +177,7 @@ trdsql -icsv -ih -ovf "SELECT * FROM header.csv"
| LTSV |||[ltsv.org](http://ltsv.org) |
| JSON |||[www.json.org](www.json.org)|
| JSONL |||入力はJSONで可能|
| YAML ||| [yaml.org] (http://yaml.org) |
| YAML ||| [yaml.org](http://yaml.org) |
| TBLN |||[tbln.dev](https://tbln.dev)|
| RAW | × || そのまま出力(エスケープ処理をしない)|
| MD | × || MarkDownテーブル |
Expand Down
2 changes: 1 addition & 1 deletion content/trdsql/03_sql.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ It's too easy to get angry, but if you use the UNIX tool, AWK or CUT will be the

## Sorting line

If you have something else to sort, it's a line.
If you have something else to sort, it's a line.
You can sort lines with `ORDER BY column name`. Ascending order (small → large) is ASC (default so can be omitted),
descending order (large → small) is DESC.

Expand Down
2 changes: 1 addition & 1 deletion content/trdsql/11_summary.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ Therefore, unlike tools that can stream one line at a time, trdsql takes time to

However, you can use real SQL, not SQL-like.

It is a good idea to use it based on these features.
It is a good idea to use it based on these features.
4 changes: 2 additions & 2 deletions content/trdsql/14_sqlite3.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Even if the file does not exist in advance, it will not cause an error.
trdsql -driver sqlite3 -dsn "test.sqlite" -oat "SELECT * FROM test"
```

```
```at
+----+--------+-------+
| id | name | price |
+----+--------+-------+
Expand Down Expand Up @@ -81,4 +81,4 @@ $ trdsql -ih -driver sqlite3 -dsn "file:trdsql_testro.db?mode=ro" "CREATE TABLE
2020/01/08 14:02:54 ERROR(BEGIN):unable to open database file: no such file or directory
```

For details of DSN options, please refer to the [go-sqlite3](https://github.com/mattn/go-sqlite3#connection-string).
For details of DSN options, please refer to the [go-sqlite3](https://github.com/mattn/go-sqlite3#connection-string).
2 changes: 1 addition & 1 deletion content/trdsql/21_json_parse.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,4 @@ trdsql -driver postgres -dsn "dbname=trdsql_test" "SELECT color,category,jsonb_p
Database JSON functions have many more functions and can edit objects in JSON. However, trdsql treats JSON columns as strings when outputting JSON, so it is not well suited for output with -ojson.
In that case, it is better to make effective use of the JSON output on the database side to output as intended.
In that case, it is better to make effective use of the JSON output on the database side to output as intended.
12 changes: 8 additions & 4 deletions content/trdsql/21_json_parse.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ sample.json
```console
trdsql -oat "SELECT color,category,code FROM sample.json"
```
```

```at
+-------+----------+-----------------------------------+
| color | category | code |
+-------+----------+-----------------------------------+
Expand All @@ -77,7 +78,8 @@ codeの中の"hex"のみを表示するには以下のようにします。
```console
trdsql -ijson -oat "SELECT color,category,json_extract(code,'\$.hex') AS hex FROM sample.json"
```
```

```at
+-------+----------+------+
| color | category | hex |
+-------+----------+------+
Expand All @@ -95,7 +97,8 @@ PostgreSQLで取得する場合は、jsonやjsonbにキャストしてから関
```console
trdsql -driver postgres -dsn "dbname=trdsql_test" "SELECT color,category,json_extract_path_text(code::json,'hex') AS hex FROM sample.json"
```
```

```at
+-------+----------+------+
| color | category | hex |
+-------+----------+------+
Expand All @@ -110,7 +113,8 @@ trdsql -driver postgres -dsn "dbname=trdsql_test" "SELECT color,category,json_ex
```console
trdsql -driver postgres -dsn "dbname=trdsql_test" "SELECT color,category,jsonb_path_query(code::jsonb,'\$.hex')::text AS hex FROM sample.json"
```
```

```at
+-------+----------+--------+
| color | category | hex |
+-------+----------+--------+
Expand Down
2 changes: 1 addition & 1 deletion content/trdsql/27_config.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ ${HOME}/.config/trdsql/config.json

### Windows

`%APPDATA%trdsql\config.json` is the default location. It is often located as follows.
`%APPDATA%trdsql\config.json` is the default location. It is often located as follows.

```path
C:\Users\{"User"}\AppData\Roaming\trdsql\config.json
Expand Down
2 changes: 1 addition & 1 deletion content/trdsql/35_jq.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ With trdsql, you can first process JSON using `jq` syntax and then execute SQL o
(When targeting JSON, the entire array is interpreted as a single column).

```console
trdsql "SELECT * FROM example0-s.json
trdsql "SELECT * FROM example0-s.json"
```

```csv
Expand Down
3 changes: 2 additions & 1 deletion content/trdsql/35_jq.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,13 @@ SQLの関数を使用して、アクセスすることも出来ますが、少
trdsqlではJSONに対し、まず`jq`の構文を使用して処理し、その結果に対してSQLを実行できます。
`jq`の構文はファイル名の後に"::"を付け、その後に書きます。
`jq`の構文なので、主に"."ドットではじまり、中の値にアクセスします。

***

(jsonを対象とすると配列全体を1つの列と解釈してしまう)。

```console
trdsql "SELECT * FROM example0-s.json
trdsql "SELECT * FROM example0-s.json"
```

```csv
Expand Down

0 comments on commit 0049d1d

Please sign in to comment.