Sha256: ce8511afcf1443138a314e0b66ddf13548aca06818806f36cd8f31c3a630786f

Contents?: true

Size: 798 Bytes

Versions: 2

Compression:

Stored size: 798 Bytes

Contents

require 'activerecord-jdbc-adapter'
require 'jdbc-vertica'
require 'dotenv'

class JdbcTest < ActiveRecord::Base
end

# Create .env file containing
# HOSTNAME=
# PORT=
# DATABASE=
# USERNAME=
# PASSWORD=
Dotenv.load

config = {
  hostname: ENV['HOSTNAME'],
  port:     ENV['PORT'] || "5433",
  username: ENV['USERNAME'],
  password: ENV['PASSWORD'],
  database: ENV['DATABASE'] || "vmain",
}
puts config

Jdbc::Vertica.load_driver
ActiveRecord::Base.establish_connection adapter: 'jdbc',
  driver: 'com.vertica.jdbc.Driver',
  url: "jdbc:vertica://#{config[:hostname]}:#{config[:port]}/",
  username: config[:username],
  password: config[:password],
  database: config[:database],
  schema_search_path: 'sandbox'
ActiveRecord::Base.connection.execute "SET search_path TO sandbox;"

p JdbcTest.all

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
jdbc-vertica-0.0.3 example/activerecord.rb
jdbc-vertica-0.0.2 example/activerecord.rb