Module: ActiveRecord::ConnectionHandling

Defined in:
lib/active_record/connection_adapters/duckdb_adapter.rb

Instance Method Summary collapse

Instance Method Details

#duckdb_connection(config) ⇒ ActiveRecord::ConnectionAdapters::DuckdbAdapter

Establishes a connection to a DuckDB database

Parameters:

  • config (Hash)

    Database configuration options

Returns:

Raises:

  • (ActiveRecord::ConnectionNotEstablished)

    If connection fails



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/active_record/connection_adapters/duckdb_adapter.rb', line 25

def duckdb_connection(config)
  config = config.symbolize_keys
  begin
    # Create adapter first, then let it establish connection
    adapter = ConnectionAdapters::DuckdbAdapter.new(nil, logger, {}, config)
    adapter.send(:connect)
    adapter
  rescue StandardError => e
    raise ActiveRecord::ConnectionNotEstablished,
          "Could not connect to DuckDB database: #{e.message}"
  end
end