Class: ClickhouseNative::Client
- Inherits:
-
Object
- Object
- ClickhouseNative::Client
- Includes:
- Logging
- Defined in:
- lib/clickhouse_native/client.rb,
lib/clickhouse_native/logging.rb,
ext/clickhouse_native/client.cpp
Constant Summary
Constants included from Logging
Instance Attribute Summary collapse
-
#database ⇒ Object
readonly
Returns the value of attribute database.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
Instance Method Summary collapse
- #describe_table(table, db_name: nil) ⇒ Object
-
#insert(table, rows, columns: nil, db_name: nil, types: nil) ⇒ Object
insert(table, rows, columns: nil, db_name: nil, types: nil).
- #inspect ⇒ Object
Methods included from Logging
#execute, #insert_block, #query, #query_each, #query_value
Instance Attribute Details
#database ⇒ Object (readonly)
Returns the value of attribute database.
5 6 7 |
# File 'lib/clickhouse_native/client.rb', line 5 def database @database end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
5 6 7 |
# File 'lib/clickhouse_native/client.rb', line 5 def host @host end |
#logger ⇒ Object
Returns the value of attribute logger.
60 61 62 |
# File 'lib/clickhouse_native/logging.rb', line 60 def logger @logger end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
5 6 7 |
# File 'lib/clickhouse_native/client.rb', line 5 def port @port end |
Instance Method Details
#describe_table(table, db_name: nil) ⇒ Object
7 8 9 10 |
# File 'lib/clickhouse_native/client.rb', line 7 def describe_table(table, db_name: nil) fq = db_name ? "#{db_name}.#{table}" : table query("DESCRIBE TABLE #{fq}") end |
#insert(table, rows, columns: nil, db_name: nil, types: nil) ⇒ Object
insert(table, rows, columns: nil, db_name: nil, types: nil)
rows may be Array<Hash=> Object> or Array<Array>. columns defaults to the first hash’s keys (for Array<Hash>) or all table columns in DDL order (for Array<Array>). types may be supplied to skip the DESCRIBE lookup.
Hash keys not present in the schema raise ArgumentError — if you need to insert a subset, pass ‘columns:` explicitly.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/clickhouse_native/client.rb', line 21 def insert(table, rows, columns: nil, db_name: nil, types: nil) return 0 if rows.empty? fq = db_name ? "#{db_name}.#{table}" : table col_pairs = if types && columns zip_columns_and_types(columns, types) else columns_from_schema(table, rows, columns, db_name, fq) end row_arrays = rows.first.is_a?(Hash) ? hash_rows_to_arrays(rows, col_pairs) : rows insert_block(fq, col_pairs, row_arrays) end |
#inspect ⇒ Object
36 37 38 |
# File 'lib/clickhouse_native/client.rb', line 36 def inspect "#<#{self.class} #{host}:#{port}/#{database}>" end |