click_house 1.2.2 → 1.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/LICENCE.txt +21 -0
- data/README.md +19 -3
- data/lib/click_house/extend/connection_inserting.rb +5 -3
- data/lib/click_house/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cbc27532a4abd9eab176f4c1816bae63d4b4d379bbd0f2ab24c4e6fd1d3a7178
|
4
|
+
data.tar.gz: ff239f24529edda890282222c8aa58e93c0d9d65f1376a1ee38a9371d770e893
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4eb18c92e8489be5b0cc63cd578ef7359619ec0972ec96f9efccc0b145a9347a8de320a34a88eaec366f99c0c2c19733d59bcd2acd3104f80e02149db6f2d2f
|
7
|
+
data.tar.gz: 59ce90b17994fb5bd334dbfb8181faf6a16d8514f302e89b673f45164ebd3a493e71fb96b02de510b70ca8cadefc232d13bb2d9d15b1cb2b2530efef43e4587d
|
data/Gemfile.lock
CHANGED
data/LICENCE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
COPYRIGHT (C) 2019 ALIAKSANDR SHYLAU
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
CHANGED
@@ -73,7 +73,8 @@ Now you are able to communicate with ClickHouse:
|
|
73
73
|
```ruby
|
74
74
|
ClickHouse.connection.ping #=> true
|
75
75
|
```
|
76
|
-
You can easily build a new raw connection
|
76
|
+
You can easily build a new raw connection and override any configuration parameter
|
77
|
+
(such as database name, connection address)
|
77
78
|
|
78
79
|
```ruby
|
79
80
|
@connection = ClickHouse::Connection.new(ClickHouse::Config.new(logger: Rails.logger))
|
@@ -175,6 +176,8 @@ response.body #=> "\u0002\u0000\u0000\u0000\u0000\u0000\u0000\u0000"
|
|
175
176
|
|
176
177
|
## Insert
|
177
178
|
|
179
|
+
When column names and values are transferred separately
|
180
|
+
|
178
181
|
```ruby
|
179
182
|
ClickHouse.connection.insert('table', columns: %i[id name]) do |buffer|
|
180
183
|
buffer << [1, 'Mercury']
|
@@ -185,6 +188,19 @@ ClickHouse.connection.insert('table', columns: %i[id name], values: [[1, 'Mercur
|
|
185
188
|
#=> true
|
186
189
|
```
|
187
190
|
|
191
|
+
When rows are passed as a hash
|
192
|
+
|
193
|
+
|
194
|
+
```ruby
|
195
|
+
ClickHouse.connection.insert('table', values: [{ name: 'Sun', id: 1 }, { name: 'Moon', id: 2 }])
|
196
|
+
|
197
|
+
ClickHouse.connection.insert('table') do |buffer|
|
198
|
+
buffer << { name: 'Sun', id: 1 }
|
199
|
+
buffer << { name: 'Moon', id: 2 }
|
200
|
+
end
|
201
|
+
#=> true
|
202
|
+
```
|
203
|
+
|
188
204
|
## Create a table
|
189
205
|
### Create table using DSL
|
190
206
|
|
@@ -442,14 +458,14 @@ You can clear the data table before each test with RSpec
|
|
442
458
|
|
443
459
|
```ruby
|
444
460
|
RSpec.configure do |config|
|
445
|
-
config.before(:each,
|
461
|
+
config.before(:each, truncate_click_house: true) do
|
446
462
|
ClickHouse.connection.truncate_tables
|
447
463
|
end
|
448
464
|
end
|
449
465
|
```
|
450
466
|
|
451
467
|
```ruby
|
452
|
-
RSpec.describe Api::MetricsCountroller,
|
468
|
+
RSpec.describe Api::MetricsCountroller, truncate_click_house: true do
|
453
469
|
it { }
|
454
470
|
it { }
|
455
471
|
end
|
@@ -3,11 +3,13 @@
|
|
3
3
|
module ClickHouse
|
4
4
|
module Extend
|
5
5
|
module ConnectionInserting
|
6
|
-
def insert(table, columns
|
6
|
+
def insert(table, columns: [], values: [])
|
7
7
|
yield(values) if block_given?
|
8
8
|
|
9
|
-
body =
|
10
|
-
|
9
|
+
body = if columns.empty?
|
10
|
+
values.map(&:to_json)
|
11
|
+
else
|
12
|
+
values.map { |value_row| columns.zip(value_row).to_h.to_json }
|
11
13
|
end
|
12
14
|
|
13
15
|
execute("INSERT INTO #{table} FORMAT JSONEachRow", body.join("\n")).success?
|
data/lib/click_house/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: click_house
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aliaksandr Shylau
|
@@ -135,6 +135,7 @@ files:
|
|
135
135
|
- ".travis.yml"
|
136
136
|
- Gemfile
|
137
137
|
- Gemfile.lock
|
138
|
+
- LICENCE.txt
|
138
139
|
- Makefile
|
139
140
|
- README.md
|
140
141
|
- Rakefile
|