Class: Remi::Encoder::Postgres

Inherits:
Remi::Encoder show all
Defined in:
lib/remi/data_subjects/postgres.rb

Overview

Postgres encoder

Instance Attribute Summary collapse

Attributes inherited from Remi::Encoder

#context, #field_symbolizer, #fields, #logger

Instance Method Summary collapse

Methods inherited from Remi::Encoder

#initialize

Constructor Details

This class inherits a constructor from Remi::Encoder

Instance Attribute Details

#valuesArray<String>

Returns All records of the dataframe encoded as strings to be used by Postgres Bulk updater.

Returns:

  • (Array<String>)

    All records of the dataframe encoded as strings to be used by Postgres Bulk updater



109
110
111
# File 'lib/remi/data_subjects/postgres.rb', line 109

def values
  @values
end

Instance Method Details

#ddl_fieldsString

Returns Field definitions to be used in the DDL.

Returns:

  • (String)

    Field definitions to be used in the DDL



122
123
124
# File 'lib/remi/data_subjects/postgres.rb', line 122

def ddl_fields
  fields.map { |k,v| "#{k} #{v[:type]}" }.join(', ')
end

#encode(dataframe) ⇒ Object

Converts the dataframe to an array of hashes, which can be used by the postgres loader.

Parameters:

Returns:

  • (Object)

    The encoded data to be loaded into the target



116
117
118
119
# File 'lib/remi/data_subjects/postgres.rb', line 116

def encode(dataframe)
  @values = encode_data(dataframe)
  self
end