Class: ActiveRecord::Base
- Inherits:
-
Object
- Object
- ActiveRecord::Base
- Defined in:
- lib/active_record/connection_adapters/vertica_adapter.rb
Class Method Summary collapse
-
.vertica_connection(config) ⇒ Object
Establishes a connection to the database that’s used by all Active Record objects.
Class Method Details
.vertica_connection(config) ⇒ Object
Establishes a connection to the database that’s used by all Active Record objects
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/active_record/connection_adapters/vertica_adapter.rb', line 7 def self.vertica_connection(config) # :nodoc: unless defined? Vertica begin require 'vertica' rescue LoadError raise "!!! Missing the vertica gem. Add it to your Gemfile: gem 'vertica'" end end config = config.symbolize_keys host = config[:host] port = config[:port] || 5433 username = config[:username].to_s if config[:username] password = config[:password].to_s if config[:password] if config.has_key?(:database) database = config[:database] else raise ArgumentError, "No database specified. Missing argument: database." end if config.has_key?(:schema) schema = config[:schema] else raise ArgumentError, "No database specified. Missing argument: schema." end conn = Vertica.connect({ :user => username, :password => password, :host => host, :port => port, :database => database , :schema => schema}) ConnectionAdapters::Vertica.new(conn) end |