Created
November 21, 2013 16:19
-
-
Save toyama0919/7584737 to your computer and use it in GitHub Desktop.
railsからredshiftに接続する ref: http://qiita.com/toyama0919/items/8de293cb11178a8b999e
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
redshift: | |
adapter: redshift | |
database: applog | |
host: *****.**********.ap-northeast-1.redshift.amazonaws.com | |
port: 5439 | |
username: app | |
password: | |
encoding: utf8 | |
pool: 5 | |
timeout: 30000 # タイムアウトは長めに |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo yum install postgresql postgresql-devel |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bundle install |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ActiveRecord::Base.establish_connection(:redshift) | |
result = ActiveRecord::Base.connection.execute "select * from table_name where log_date='#{d.strftime("%Y-%m-%d")}'" | |
result.each{|record| | |
p record # hash | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gem "activerecord-redshift-adapter" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment