Skip to content

Commit

Permalink
cleanup readme
Browse files Browse the repository at this point in the history
  • Loading branch information
ruslandoga committed Dec 29, 2023
1 parent 06665e6 commit 6965b03
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,6 @@ Ch.query!(pid, "CREATE TABLE IF NOT EXISTS ch_demo(id UInt64) ENGINE Null")
%Ch.Result{num_rows: 2} =
Ch.query!(pid, "INSERT INTO ch_demo(id) VALUES (0), (1)")

%Ch.Result{num_rows: 2} =
Ch.query!(pid, "INSERT INTO ch_demo(id) VALUES ({$0:UInt8}), ({$1:UInt32})", [0, 1])

%Ch.Result{num_rows: 2} =
Ch.query!(pid, "INSERT INTO ch_demo(id) VALUES ({a:UInt16}), ({b:UInt64})", %{"a" => 0, "b" => 1})

Expand Down Expand Up @@ -117,7 +114,10 @@ header = Ch.RowBinary.encode_names_and_types(names, types)
row_binary = Ch.RowBinary.encode_rows(rows, types)

%Ch.Result{num_rows: 3} =
Ch.query!(pid, ["INSERT INTO ch_demo FORMAT RowBinaryWithNamesAndTypes\n", header | row_binary])
Ch.query!(pid, [
"INSERT INTO ch_demo FORMAT RowBinaryWithNamesAndTypes\n",
header | row_binary
])
```

#### Insert rows in custom [format](https://clickhouse.com/docs/en/interfaces/formats)
Expand Down Expand Up @@ -147,7 +147,12 @@ row_binary =
|> Stream.take(10)

%Ch.Result{num_rows: 1_000_000} =
Ch.query(pid, Stream.concat(["INSERT INTO ch_demo(id) FORMAT RowBinary\n"], row_binary))
Ch.query(pid,
Stream.concat(
["INSERT INTO ch_demo(id) FORMAT RowBinary\n"],
row_binary
)
)
```

#### Insert rows via [input](https://clickhouse.com/docs/en/sql-reference/table-functions/input) function
Expand Down Expand Up @@ -247,8 +252,8 @@ row_binary = Ch.RowBinary.encode(:string, "\x61\xF0\x80\x80\x80b")
%Ch.Result{rows: [["a�b"]]} =
Ch.query!(pid, "SELECT * FROM ch_utf8")

%Ch.Result{rows: %{"data" => [["a�b"]]}} =
pid |> Ch.query!("SELECT * FROM ch_utf8 FORMAT JSONCompact") |> Map.update!(:rows, &Jason.decode!/1)
%{"data" => [["a�b"]]} =
pid |> Ch.query!("SELECT * FROM ch_utf8 FORMAT JSONCompact").data |> Jason.decode!()
```

#### Timezones in RowBinary
Expand Down

0 comments on commit 6965b03

Please sign in to comment.