Giter VIP home page Giter VIP logo

activerecord-redshift-adapter's Introduction

activerecord-redshift-adapter

adapter for aws redshift for rails 3

Ripped from rails 3 postgresql.

example database.yml

common: &common
  adapter: postgresql
  username: postgres
  encoding: SQL_ASCII
  template: template0
  pool: 5
  timeout: 5000

redshiftdb: &redshiftdb
  adapter: redshift
  host: clustername.something.us-east-1.redshift.amazonaws.com
  database: databasename
  port: 5439
  username: username
  password: password

redshift_development:
  <<: *common
  <<: *redshiftdb
  database: databasename

options

<table>
  <tr>
    <th>option</th>
    <th>description</th>
  </tr>
  <tr>
    <th>schema_search_path</th>
    <td>set schema_search_path. use default value if not given.</td>
  </tr>
  <tr>
    <th>read_timezone</th>
    <td>force timezone for datetime when select values. ActiveRecord default timezone will set if not given.</td>
  </tr>
</table>

Have you considered using Partitioned gem? It works with redshift!

https://github.com/fiksu/partitioned

TableManager

Helpful code to clone redshift tables

create table foos
(
  id int not null primary key distkey,
   name varchar(255) unique sortkey
);
class Foo < ActiveRecord::Base
end

require 'activerecord_redshift_adapter'

table_manager = ActiverecordRedshift::TableManager.new(Foo.connection, :exemplar_table_name => Foo.table_name)
table_manager.duplicate_table

yields:

  select oid from pg_namespace where nspname = 'public' limit 1;

  select oid,reldiststyle from pg_class where relnamespace = 2200 and relname = 'foos' limit 1;

  select contype,conkey from pg_constraint where connamespace = 2200 and conrelid = 212591;

  select attname,attnum from pg_attribute where attrelid = 212591 and attnum in (2,1);

  show search_path;

  set search_path = 'public';

  select * from pg_table_def where tablename = 'foos' and schemaname = 'public';

  create temporary table temporary_events_25343
  (
   id integer not null distkey,
   name character varying(255),
   primary key (id),
   unique (name)
  ) sortkey (name);

  set search_path = '$user','public';

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.