Class: Turboquery::OLTP
- Inherits:
-
Connection
- Object
- Connection
- Turboquery::OLTP
- Defined in:
- lib/turboquery/oltp.rb
Defined Under Namespace
Classes: AROLTP
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Connection
#after_fork, #config, #dump_table_ddl, #execute, #set_env, #table_exists?
Class Method Details
Instance Method Details
#copy_s3_to_table(key, table) ⇒ Object
17 18 19 20 21 22 23 |
# 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) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 |
# 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 |