Class: ChConnect::Connection
- Inherits:
-
Object
- Object
- ChConnect::Connection
- Defined in:
- lib/ch_connect/connection.rb
Overview
A single connection to ClickHouse server.
Instance Attribute Summary collapse
-
#config ⇒ Config
readonly
The configuration used by this connection.
Instance Method Summary collapse
-
#initialize(config = ChConnect.config) ⇒ Connection
constructor
Creates a new connection.
-
#query(sql, options = {}) ⇒ Response
Executes a SQL query and returns the response.
Constructor Details
#initialize(config = ChConnect.config) ⇒ Connection
Creates a new connection.
16 17 18 19 |
# File 'lib/ch_connect/connection.rb', line 16 def initialize(config = ChConnect.config) @config = config @transport = HttpTransport.new(config) end |
Instance Attribute Details
#config ⇒ Config (readonly)
Returns the configuration used by this connection.
11 12 13 |
# File 'lib/ch_connect/connection.rb', line 11 def config @config end |
Instance Method Details
#query(sql, options = {}) ⇒ Response
Executes a SQL query and returns the response.
28 29 30 31 32 33 |
# File 'lib/ch_connect/connection.rb', line 28 def query(sql, = {}) @config.instrumenter.instrument("query.clickhouse", {sql: sql}) do result = @transport.execute(sql, ) NativeFormatParser.new(result.body).parse.with(summary: result.summary) end end |