Class: Remi::Parser::Postgres
- Inherits:
-
Remi::Parser
- Object
- Remi::Parser
- Remi::Parser::Postgres
- Defined in:
- lib/remi/data_subjects/postgres.rb
Overview
Postgres parser Used to parse results from a postgres extractor (see Extractor::Postgres).
Instance Attribute Summary
Attributes inherited from Remi::Parser
#context, #field_symbolizer, #fields, #logger
Instance Method Summary collapse
-
#parse(postgres_extract) ⇒ Remi::DataFrame
The data converted into a dataframe.
Methods inherited from Remi::Parser
Constructor Details
This class inherits a constructor from Remi::Parser
Instance Method Details
#parse(postgres_extract) ⇒ Remi::DataFrame
Returns The data converted into a dataframe.
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/remi/data_subjects/postgres.rb', line 86 def parse(postgres_extract) # Performance for larger sets could be improved by using bulk query (via COPY) logger.info "Converting Postgres query to a dataframe" hash_array = {} postgres_extract.data.each do |row| row.each do |field, value| (hash_array[field_symbolizer.call(field)] ||= []) << value end end # After converting to DF, clear the PG results to save memory. postgres_extract.data.clear Remi::DataFrame.create(:daru, hash_array, order: hash_array.keys) end |