Sha256: b85e5b65861f1a6a8636a6a42caf1703cff7cc64f0e35d68aca91080415b6b3a

Contents?: true

Size: 767 Bytes

Versions: 1

Compression:

Stored size: 767 Bytes

Contents

require 'jvertica'
require 'dotenv'

# Create .env file like
# HOSTNAME=
# USERNAME=
# PASSWORD=
Dotenv.load

params = {
  host: ENV['HOSTNAME'],
  port: 5433,
  user: ENV['USERNAME'],
  password: ENV['PASSWORD'],
}
puts params

vertica = Jvertica.connect(params)
vertica.query("DROP TABLE sandbox.jvertica_test") rescue nil
vertica.query("CREATE TABLE sandbox.jvertica_test (id integer, str varchar(80))")
vertica.copy("COPY sandbox.jvertica_test FROM STDIN PARSER fjsonparser() NO COMMIT") do |io|
  File.open(File.expand_path('../data.json', __FILE__), 'r') do |f|
    begin
      io << f.gets
    end until f.eof?
  end
end
vertica.commit
vertica.query("SELECT * from sandbox.jvertica_test") do |row|
  p row
end
vertica.query("DROP TABLE sandbox.jvertica_test")

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jvertica-0.1.10 example/copy.rb