class Turboquery::OLTP

Public Class Methods

after_fork() click to toggle source
# File lib/turboquery/oltp.rb, line 25
def self.after_fork
  AROLTP.connect
end

Public Instance Methods

copy_s3_to_table(key, table) click to toggle source
# File lib/turboquery/oltp.rb, line 17
def copy_s3_to_table(key, table)
  set_env
  path = copy_s3_to_tmp(key)
  sql = "COPY #{table} FROM STDIN"
  command = "cat #{Shellwords.escape(path)} | psql -c #{Shellwords.escape(sql)} #{Shellwords.escape(config[:database])}"
  Kernel.system(command)
end
copy_table_to_s3(table) click to toggle source
# File lib/turboquery/oltp.rb, line 4
def copy_table_to_s3(table)
  set_env

  temp = Tempfile.new('turboquery', Turboquery.tmp_path)
  command = "echo 'COPY #{table} TO STDOUT' | psql #{Shellwords.escape(config[:database])} > #{temp.path}"
  Kernel.system(command)

  key = random_key
  copy_file_to_s3(temp.path, key)
  upload_manifest(key)
  key
end

Protected Instance Methods

connection() click to toggle source
# File lib/turboquery/oltp.rb, line 31
def connection
  AROLTP.connection
end