A little library to help you work with GoodData's Datawarehouse
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
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')
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.
- Fork it ( https://github.com/[my-github-username]/gooddata_datawarehouse/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request