gooddata_datawarehouse 0.0.9 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bbb47425e959803a032aadd5eafa8b1b40c0ba1695648a49c8c3bed737be40b2
4
- data.tar.gz: c81839b299f2c9cab6a5cced6fa403e7edd9f287fa05d02aa5d23c52139dd9ae
3
+ metadata.gz: 8b921d1b0bbe1457b707f798c19f0a960edd456459b937c4b2e8da9712df85ab
4
+ data.tar.gz: 4a79964523cd16ad3cd84ed62cd18e84b0472403b986960c21d607dbecd6445c
5
5
  SHA512:
6
- metadata.gz: 5225c46a79009619c6eaab6651d3d8f3d5f636572daa1db6ab9a27240a78e85bb77d7312957b89733da5df1a784c48fe7acb81f5ee5d2fdb1e625c43c4b3945d
7
- data.tar.gz: 9eaf09fb89d312a544f33d357505ce95b44c3f5a1068ecce6a4dbbe80e06a99b2442050678976d866f6ea4023f452cd66d0fb19bc9cb725751ab55b47ec49f76
6
+ metadata.gz: 3ea0f80a4e10b4e0177689d9c319aa932b69561220cfd13306fcd4db7528ede9fbe5e79b045c485e91cde0a74469c1d0f2e28db7aa123a4a153da7133c5c65cd
7
+ data.tar.gz: 62fa5a6c6c49380d60ae0d0ea543f9554bab48c7cd3b2fd4aef9e784d60c7d904d64bc2fc8a0a9af1ac35f976d6863f0c18ff35a8dd9ff1eda0551b2d7cc9424
data/README.md CHANGED
@@ -50,6 +50,12 @@ dwh = GoodData::Datawarehouse.new('you@gooddata.com', 'yourpass', 'your ADS inst
50
50
  # for custom jdbc url do:
51
51
  # dwh = GoodData::Datawarehouse.new('you@gooddata.com', 'yourpass', nil, :jdbc_url => 'jdbc:dss://whatever.com/something')
52
52
 
53
+ # connect with SST (available from version 0.0.10)
54
+ # dwh = GoodData::Datawarehouse.new_instance(:instance_id => 'your ADS instance id', :sst => 'SST token')
55
+ # for custom jdbc url do:
56
+ # dwh = GoodData::Datawarehouse.new_instance(:jdbc_url => 'jdbc:dss://whatever.com/something', :sst => 'SST token')
57
+
58
+
53
59
  # import a csv
54
60
  dwh.csv_to_new_table('my_table', 'path/to/my.csv')
55
61
 
@@ -10,14 +10,17 @@ require_relative 'sql_generator'
10
10
  module GoodData
11
11
  class Datawarehouse
12
12
  PARALEL_COPY_THREAD_COUNT = 10
13
+
14
+ def self.new_instance(opts={})
15
+ self.new(opts[:username], opts[:password], opts[:instance_id], opts)
16
+ end
17
+
13
18
  def initialize(username, password, instance_id, opts={})
14
19
  @logger = Logger.new(STDOUT)
15
20
  @username = username
16
21
  @password = password
22
+ @sst_token = opts[:sst]
17
23
  @jdbc_url = opts[:jdbc_url] || "jdbc:gdc:datawarehouse://secure.gooddata.com/gdc/datawarehouse/instances/#{instance_id}"
18
- if @username.nil? || @password.nil?
19
- fail ArgumentError, "username and/or password are nil. All of them are mandatory."
20
- end
21
24
 
22
25
  if instance_id.nil? && opts[:jdbc_url].nil?
23
26
  fail ArgumentError, "you must either provide instance_id or jdbc_url option."
@@ -192,11 +195,15 @@ module GoodData
192
195
  end
193
196
 
194
197
  def connect
195
- Sequel.connect @jdbc_url,
196
- :username => @username,
197
- :password => @password do |connection|
198
- yield(connection)
198
+ if @username.to_s.empty? || @password.to_s.empty?
199
+ @connection = Sequel.connect(@jdbc_url, :driver => Java.com.gooddata.dss.jdbc.driver.DssDriver, :jdbc_properties => {'sst' => @sst_token})
200
+ else
201
+ @connection = Sequel.connect(@jdbc_url, :username => @username, :password => @password)
199
202
  end
203
+ yield(@connection)
204
+ ensure
205
+ @connection.disconnect unless @connection.nil?
206
+ Sequel.synchronize{::Sequel::DATABASES.delete(@connection)}
200
207
  end
201
208
 
202
209
  private
@@ -1,5 +1,5 @@
1
1
  module GoodData
2
2
  class Datawarehouse
3
- VERSION = "0.0.9"
3
+ VERSION = "0.0.10"
4
4
  end
5
5
  end
@@ -7,10 +7,17 @@ WRONG_CSV_PATH = 'spec/data/wrong-bike.csv'
7
7
  EMPTY_HEADER_CSV_PATH = 'spec/data/emptyheader-bike.csv'
8
8
  CSV_REGEXP = 'spec/data/bike*.csv'
9
9
 
10
+ SST_TOKEN = ENV['GDC_SST']
11
+
10
12
  class Helper
11
13
  def self.create_default_connection
12
14
  GoodData::Datawarehouse.new(ENV['USERNAME'], ENV['PASSWORD'], ENV['INSTANCE_ID'])
13
15
  end
16
+
17
+ def self.create_connection_with_sst
18
+ GoodData::Datawarehouse.new_instance(:jdbc_url => ENV['JDBC_URL'], :sst => SST_TOKEN)
19
+ end
20
+
14
21
  def self.line_count(f)
15
22
  i = 0
16
23
  CSV.foreach(f, :headers => true) {|_| i += 1}
@@ -21,13 +28,23 @@ end
21
28
  describe GoodData::Datawarehouse do
22
29
  describe "dwh instance creation" do
23
30
  it "creates an instance with custom jdbc url" do
24
- dwh = GoodData::Datawarehouse.new(ENV['USERNAME'], ENV['PASSWORD'], nil, :jdbc_url => "jdbc:dss://secure.gooddata.com/gdc/dss/instances/#{ENV['INSTANCE_ID']}")
25
- expect(dwh.table_exists?('hahahaha')).to eq false
31
+ if SST_TOKEN.to_s.empty?
32
+ dwh = GoodData::Datawarehouse.new(ENV['USERNAME'], ENV['PASSWORD'], nil, :jdbc_url => "jdbc:dss://secure.gooddata.com/gdc/dss/instances/#{ENV['INSTANCE_ID']}")
33
+ expect(dwh.table_exists?('hahahaha')).to eq false
34
+ else
35
+ dwh = Helper::create_connection_with_sst
36
+ expect(dwh.table_exists?('hahahaha')).to eq false
37
+ end
26
38
  end
27
39
  end
40
+
28
41
  describe 'Table operations' do
29
42
  before(:each) do
30
- @dwh = Helper::create_default_connection
43
+ if SST_TOKEN.to_s.empty?
44
+ @dwh = Helper::create_default_connection
45
+ else
46
+ @dwh = Helper::create_connection_with_sst
47
+ end
31
48
  @random = rand(10000000).to_s
32
49
  @random_table_name = "temp_#{@random}"
33
50
  @created_tables = nil
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gooddata_datawarehouse
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Petr Cvengros
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-07 00:00:00.000000000 Z
11
+ date: 2019-08-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -69,23 +69,23 @@ dependencies:
69
69
  - !ruby/object:Gem::Dependency
70
70
  requirement: !ruby/object:Gem::Requirement
71
71
  requirements:
72
- - - "~>"
73
- - !ruby/object:Gem::Version
74
- version: '0.7'
75
72
  - - ">="
76
73
  - !ruby/object:Gem::Version
77
74
  version: 0.7.0
75
+ - - "~>"
76
+ - !ruby/object:Gem::Version
77
+ version: '0.7'
78
78
  name: coveralls
79
79
  prerelease: false
80
80
  type: :development
81
81
  version_requirements: !ruby/object:Gem::Requirement
82
82
  requirements:
83
- - - "~>"
84
- - !ruby/object:Gem::Version
85
- version: '0.7'
86
83
  - - ">="
87
84
  - !ruby/object:Gem::Version
88
85
  version: 0.7.0
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '0.7'
89
89
  - !ruby/object:Gem::Dependency
90
90
  requirement: !ruby/object:Gem::Requirement
91
91
  requirements:
@@ -176,7 +176,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
176
176
  version: '0'
177
177
  requirements: []
178
178
  rubyforge_project:
179
- rubygems_version: 2.6.13
179
+ rubygems_version: 2.7.9
180
180
  signing_key:
181
181
  specification_version: 4
182
182
  summary: Convenient work with GoodData's Datawarehouse (ADS)