No commit activity in last 3 years
No release in over 3 years
There's a lot of open issues
redshift-connector is a bulk data connector for Rails (ActiveRecord).
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

Redshift Connector for Rails

redshift_connector is a Redshift bulk data connector for Rails (ActiveRecord).

This library is formerly called as "redshift-connector", but renamed to "redshift_connector" to follow the gem naming standard.

Settings

Add following block to your Gemfile and bundle.

gem 'redshift_connector'

Add config/initializers/redshift_connector.rb like following:

module RedshiftConnector
  Exporter.default_data_source = Any_ActiveRecord_Class_Bound_To_Redshift

  S3Bucket.add('primary', default: true,
    region: 'YOUR_AWS_REGION_NAME',
    bucket: 'YOUR_BUCKET_NAME',
    prefix: 'YOUR_PREFIX',
    iam_role: 'arn:aws:iam::XXXXXXXXXXXX:role/RedshiftReadOnly'
    # For explicit S3 access, use following:
    # aws_access_key_id: 'XXXXXXXXXXXXX',
    # aws_secret_access_key: 'XXXXXXXXXXXXX'
  )
end

Usage

Fetching rows

RedshiftConnector.foreach(schema: 'app_mst', table: 'shops', query: 'select id, name from app_mst.shops') do |id, name|
  p [id, name]
end

schema and table is the source table name (written in the query). This method executes Redshift UNLOAD statement with given query and unload result to the intermediate S3, then read contents.