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
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 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/active_record/connection_adapters/vertica_adapter.rb', line 9 def self.vertica_connection(config) unless defined? Vertica begin require 'vertica' rescue LoadError raise "Vertica Gem not installed" 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] schema = config[:schema].to_s if config[:schema] 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, "Vertica Schema must be specified." # end conn = Vertica.connect({ :user => username, :password => password, :host => host, :port => port, :database => database, :schema => schema }) = [host, username, password, database, port,schema] ConnectionAdapters::VerticaAdapter.new(conn, , config) end |