Class: Janko::CopyImporter
- Inherits:
-
Object
- Object
- Janko::CopyImporter
- Includes:
- Agrippa::Mutable
- Defined in:
- lib/janko/copy_importer.rb
Instance Method Summary collapse
Instance Method Details
#push(values) ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/janko/copy_importer.rb', line 16 def push(values) begin line = CSV.generate_line(columns.pack(values)) connection.put_copy_data(line) rescue stop raise end self end |
#start ⇒ Object
10 11 12 13 14 |
# File 'lib/janko/copy_importer.rb', line 10 def start connection.async_exec(sprintf("COPY %s(%s) FROM STDOUT CSV", table, columns.to_list)) self end |
#stop ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/janko/copy_importer.rb', line 27 def stop connection.put_copy_end result = connection.get_last_result return(self) if (result.result_status == PG::PGRES_COMMAND_OK) return(self) if (result.result_status == PG::PGRES_COPY_IN) raise(PG::Error, result.) self end |