redshift-connector 4.3.0 → 4.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +29 -0
- data/lib/redshift-connector/s3_bucket.rb +6 -2
- data/lib/redshift-connector/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0ed37ac9fef3effe7b2e9c2c288be44f2d942d35
|
4
|
+
data.tar.gz: 5b8b27e51b258609c83b2f06d3df3268e78cccfa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db50e26f55babb5e0e897d08799001e5f3dd5f4a69375711e9275f52edc6d4a6ada9b6543f185ce8de80459d39e51c7576b7de7f1990b3b9f824c70d5fb669e8
|
7
|
+
data.tar.gz: a1147ff8f8d20624c80674c49857c80a00ac0684235b5bd90c0f0ab8e86e32ab316e343cefd362b5d1fd8139c5fe79ffb9b79c3795de0a478d43a169611eb2b7
|
data/README.md
CHANGED
@@ -8,3 +8,32 @@ Add following block to your Gemfile and bundle.
|
|
8
8
|
```
|
9
9
|
gem 'redshift-connector'
|
10
10
|
```
|
11
|
+
Add config/initializers/redshift-connector.rb like following:
|
12
|
+
```
|
13
|
+
module RedshiftConnector
|
14
|
+
Exporter.default_data_source = Any_ActiveRecord_Class_Bound_To_Redshift
|
15
|
+
|
16
|
+
S3Bucket.add('primary', default: true,
|
17
|
+
region: 'YOUR_AWS_REGION_NAME',
|
18
|
+
bucket: 'YOUR_BUCKET_NAME',
|
19
|
+
prefix: 'YOUR_PREFIX',
|
20
|
+
iam_role: 'arn:aws:iam::XXXXXXXXXXXX:role/RedshiftReadOnly'
|
21
|
+
# For explicit S3 access, use following:
|
22
|
+
# aws_access_key_id: 'XXXXXXXXXXXXX',
|
23
|
+
# aws_secret_access_key: 'XXXXXXXXXXXXX'
|
24
|
+
)
|
25
|
+
end
|
26
|
+
```
|
27
|
+
|
28
|
+
## Usage
|
29
|
+
|
30
|
+
### Fetching rows
|
31
|
+
|
32
|
+
```
|
33
|
+
RedshiftConnector.foreach(schema: 'app_mst', table: 'shops', query: 'select id, name from app_mst.shops') do |id, name|
|
34
|
+
p [id, name]
|
35
|
+
end
|
36
|
+
```
|
37
|
+
`schema` and `table` is the source table name (written in the query).
|
38
|
+
This method executes Redshift UNLOAD statement with given query and
|
39
|
+
unload result to the intermediate S3, then read contents.
|
@@ -21,7 +21,8 @@ module RedshiftConnector
|
|
21
21
|
@buckets[name.to_s] or raise ArgumentError, "no such S3 bucket configured: #{name.inspect}"
|
22
22
|
end
|
23
23
|
|
24
|
-
def initialize(bucket:, prefix: nil, access_key_id: nil, secret_access_key: nil, iam_role: nil)
|
24
|
+
def initialize(region: nil, bucket:, prefix: nil, access_key_id: nil, secret_access_key: nil, iam_role: nil)
|
25
|
+
@region = region
|
25
26
|
@name = bucket
|
26
27
|
@prefix = prefix
|
27
28
|
@access_key_id = access_key_id
|
@@ -37,7 +38,10 @@ module RedshiftConnector
|
|
37
38
|
end
|
38
39
|
|
39
40
|
def client
|
40
|
-
@client ||=
|
41
|
+
@client ||= begin
|
42
|
+
args = { region: @region, access_key_id: @access_key_id, secret_access_key: @secret_access_key }.reject {|k, v| v.nil? }
|
43
|
+
Aws::S3::Client.new(**args)
|
44
|
+
end
|
41
45
|
end
|
42
46
|
|
43
47
|
def bucket
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redshift-connector
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.3.
|
4
|
+
version: 4.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Minero Aoki
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-02-
|
11
|
+
date: 2017-02-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|