создаем таблицу
❯ curl -d "" "http://127.0.0.1:8123/?query=CREATE+TABLE+test+(x+UInt32,+y+String,+z+String)+ENGINE+=+TinyLog;"
смотрим формат входящих данных для VALUES
❯ cat example.values
(1, 'foo', 'bar'),
(2, 'foo', 'baz'),
(3, 'fxx', 'bxx')
отправляем POSTом содержимое файла
❯ cat example.values | curl --data-binary "@-" "http://127.0.0.1:8123/?query=INSERT+INTO+test+(x,+y,+z)+FORMAT+Values"
смотрим результат
❯ curl "http://127.0.0.1:8123/?query=SELECT+*+FROM+test+FORMAT+PrettyCompactNoEscapes;"
┌─x─┬─y───┬─z───┐
│ 1 │ foo │ bar │
│ 2 │ foo │ baz │
│ 3 │ fxx │ bxx │
└───┴─────┴─────┘
пересоздаем таблицу
❯ curl --data-binary "" "http://127.0.0.1:8123/?query=DROP+TABLE+test;"
❯ curl --data-binary "" "http://127.0.0.1:8123/?query=CREATE+TABLE+test+(x+UInt32,+y+String,+z+String)+ENGINE+=+TinyLog;"
смотрим формат входящих данных для TSV
❯ cat example.tsv
1 foo bar
2 foo baz
3 fxx bxx
отправляем POSTом содержимое файла
❯ cat example.tsv | curl --data-binary "@-" "http://127.0.0.1:8123/?query=INSERT+INTO+test+(x,+y,+z)+FORMAT+TabSeparated"
смотрим результат
❯ curl "http://127.0.0.1:8123/?query=SELECT+*+FROM+test+FORMAT+PrettyCompactNoEscapes;"
┌─x─┬─y───┬─z───┐
│ 1 │ foo │ bar │
│ 2 │ foo │ baz │
│ 3 │ fxx │ bxx │
└───┴─────┴─────┘
с gzip компрессией как-то так:
❯ curl --data-binary "" "http://127.0.0.1:8123/?query=DROP+TABLE+test;"
❯ curl --data-binary "" "http://127.0.0.1:8123/?query=CREATE+TABLE+test+(x+UInt32,+y+String,+z+String)+ENGINE+=+TinyLog;"
❯ time cat example.values | gzip --to-stdout | curl --data-binary "@-" "http://127.0.0.1:8123/?query=INSERT+INTO+test+(x,+y,+z)+FORMAT+Values&enable_http_compression=1" -H 'Content-Encoding: gzip'
❯ curl --data-binary "" "http://127.0.0.1:8123/?query=DROP+TABLE+test;"
❯ curl --data-binary "" "http://127.0.0.1:8123/?query=CREATE+TABLE+test+(x+UInt32,+y+String,+z+String)+ENGINE+=+TinyLog;"
❯ time cat example.tsv | gzip --to-stdout | curl --data-binary "@-" "http://127.0.0.1:8123/?query=INSERT+INTO+test+(x,+y,+z)+FORMAT+TabSeparated&enable_http_compression=1" -H 'Content-Encoding: gzip'
How to attach a multiple colums csv file to read all columns in
SELECT * FROM csv_rows
query?