Class: Remi::Extractor::Postgres

Inherits:
Remi::Extractor show all
Includes:
DataSubject::Postgres
Defined in:
lib/remi/data_subjects/postgres.rb

Overview

Postgres extractor

Examples:

class MyJob < Remi::Job
  source :some_table do
    extractor Remi::Extractor::Postgres.new(
      credentials: {
        dbname: 'my_local_db'
      },
      query: 'SELECT * FROM job_specs'
    )
    parser Remi::Parser::Postgres.new
  end
end

job = MyJob.new
job.some_table.df[:id, :name]
# =>#<Daru::DataFrame:70153144824760 @name = 53c8e878-55e7-4859-bc34-ec29309c11fd @size = 3>
#                    id       name
#          0         24 albert
#          1         26 betsy
#          2         25 camu

Instance Attribute Summary collapse

Attributes inherited from Remi::Extractor

#logger

Instance Method Summary collapse

Methods included from DataSubject::Postgres

#connection

Constructor Details

#initialize(*args, **kargs, &block) ⇒ Postgres

Returns a new instance of Postgres.

Parameters:

  • credentials (Hash)

    Used to authenticate with the postgres db

  • query (String)

    Query to use to extract data



52
53
54
55
# File 'lib/remi/data_subjects/postgres.rb', line 52

def initialize(*args, **kargs, &block)
  super
  init_postgres_extractor(*args, **kargs, &block)
end

Instance Attribute Details

#dataObject (readonly)

Returns Data extracted from Postgres system.

Returns:

  • (Object)

    Data extracted from Postgres system



58
59
60
# File 'lib/remi/data_subjects/postgres.rb', line 58

def data
  @data
end

Instance Method Details

#extractObject

Returns self after querying Postgres data.

Returns:

  • (Object)

    self after querying Postgres data



61
62
63
64
65
# File 'lib/remi/data_subjects/postgres.rb', line 61

def extract
  logger.info "Executing Postgres query #{@query}"
  @data = execute_query
  self
end