Class: Kiba::Plus::Destination::PgBulk
- Inherits:
-
Object
- Object
- Kiba::Plus::Destination::PgBulk
- Includes:
- PgBulkUtils, Helper
- Defined in:
- lib/kiba/plus/destination/pg_bulk.rb
Instance Attribute Summary collapse
-
#conn ⇒ Object
readonly
Returns the value of attribute conn.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(options = {}) ⇒ PgBulk
constructor
A new instance of PgBulk.
- #write(row) ⇒ Object
Methods included from Helper
#format_sql, #mysql2_connect_hash, #scheme
Constructor Details
#initialize(options = {}) ⇒ PgBulk
Returns a new instance of PgBulk.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/kiba/plus/destination/pg_bulk.rb', line 8 def initialize( = {}) @options = @options.assert_valid_keys( :connect_url, :schema, :table_name, :columns, :truncate, :incremental, :unique_by, :input_file, :ignore_input_file_header ) @conn = PG.connect(connect_url) @conn.exec "SET search_path TO %s" % [ [:schema] ] if [:schema] init end |
Instance Attribute Details
#conn ⇒ Object (readonly)
Returns the value of attribute conn.
6 7 8 |
# File 'lib/kiba/plus/destination/pg_bulk.rb', line 6 def conn @conn end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'lib/kiba/plus/destination/pg_bulk.rb', line 6 def @options end |
Instance Method Details
#close ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/kiba/plus/destination/pg_bulk.rb', line 30 def close if incremental drop_staging_table create_staging_table copy_to_staging_table merge_to_target_table drop_staging_table else copy_to_target_table end @conn.close @conn = nil end |
#write(row) ⇒ Object
26 27 28 |
# File 'lib/kiba/plus/destination/pg_bulk.rb', line 26 def write(row) # blank! end |