Class: ActiveRecord::Base
- Inherits:
-
Object
- Object
- ActiveRecord::Base
- Defined in:
- lib/active_record/connection_adapters/clickhouse_adapter.rb
Class Method Summary collapse
-
.clickhouse_connection(config) ⇒ Object
Establishes a connection to the database that’s used by all Active Record objects.
Class Method Details
.clickhouse_connection(config) ⇒ Object
Establishes a connection to the database that’s used by all Active Record objects
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/active_record/connection_adapters/clickhouse_adapter.rb', line 22 def clickhouse_connection(config) config = config.symbolize_keys if config[:connection] connection = { connection: config[:connection] } else port = config[:port] || 8123 connection = { host: config[:host] || 'localhost', port: port, ssl: config[:ssl].present? ? config[:ssl] : port == 443, sslca: config[:sslca], read_timeout: config[:read_timeout], write_timeout: config[:write_timeout], keep_alive_timeout: config[:keep_alive_timeout] } end if config.key?(:database) database = config[:database] else raise ArgumentError, 'No database specified. Missing argument: database.' end ConnectionAdapters::ClickhouseAdapter.new(logger, connection, config) end |