Skip to content

Small Ruby library for convenient work with GoodData's Datawarehouse (ADS)

License

Notifications You must be signed in to change notification settings

phong-nguyen-duy/gooddata_datawarehouse

 
 

Repository files navigation

GooddataDatawarehouse

A little library to help you work with GoodData's Datawarehouse

Status

Gem Version Downloads Dependency Status Code Climate Build Status Coverage Status

Installation

You need to run jRuby to use this gem, the gem won't work on any other Ruby platform than jRuby. That's because there's a dependency on the JDBC driver

If you're using rvm (recommended), run:

$ rvm use jruby

If you don't have jruby yet, run

$ rvm install jruby

Add this line to your application's Gemfile:

gem 'gooddata_datawarehouse'

And then install:

$ bundle install

Or install it yourself as:

$ gem install gooddata_datawarehouse

Usage

require 'gooddata_datawarehouse'

# connect
dwh = GoodData::Datawarehouse.new('[email protected]', 'yourpass', 'your ADS instance id')
# instance id is the identifier of your datawarehouse (ADS). 
# E.g. for datawarehouse https://secure.gooddata.com/gdc/datawarehouse/instances/d4979ac54df8afb7b5192b0086de6270
# the instance id is d4979ac54df8afb7b5192b0086de6270
# for custom jdbc url do:
# dwh = GoodData::Datawarehouse.new('[email protected]', 'yourpass', nil, :jdbc_url => 'jdbc:dss://whatever.com/something')

# connect with SST (available from version 0.0.10)
# dwh = GoodData::Datawarehouse.new_instance(:instance_id => 'your ADS instance id', :sst => 'SST token')
# for custom jdbc url do:
# dwh = GoodData::Datawarehouse.new_instance(:jdbc_url => 'jdbc:dss://whatever.com/something', :sst => 'SST token')
 

# import a csv
dwh.csv_to_new_table('my_table', 'path/to/my.csv')

# or multiple csvs (running in parallel threads)
dwh.csv_to_new_table('my_table', ['path/to/my.csv', 'path/to/my2.csv'])
dwh.csv_to_new_table('my_table', 'path/to/*.csv')
dwh.csv_to_new_table('my_table', 'path/to/directory/')

dwh.table_exists?('my_table') # true
dwh.table_row_count('my_table') # 55
dwh.get_columns('my_table') # [{column_name: 'col1', data_type: 'varchar(88)'}, {column_name: 'col2', data_type: 'int'}]

# run an arbitrary sql
dwh.execute('ALTER TABLE my_table ADD COLUMN col3 INTEGER')

# run a select and process results 
dwh.execute_select('SELECT * FROM my_table ORDER BY col1') do |row| 
  puts row[:col1] 
end

# rename a table
dwh.rename_table('my_table', 'my_new_table')

# export to csv
dwh.export_table('my_new_table', 'path/to/my_new.csv')

# drop table
dwh.drop_table('my_new_table')

Troubleshooting

Wrong driver version

If you get an error talking about handshake error and wrong DSS driver version, update your gooddata-dss-jdbc gem by running

$ bundle update

or

$ gem update gooddata-dss-jdbc

You should always have the latest version of this gem.

Contributing

  1. Fork it ( https://github.com/[my-github-username]/gooddata_datawarehouse/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

About

Small Ruby library for convenient work with GoodData's Datawarehouse (ADS)

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 98.1%
  • Shell 1.9%