You are viewing our older product's guide. Click here for the documentation of GoodData Cloud, our latest and most advanced product.
Example Ruby code for Data Warehouse
The following Ruby script provides a simple example for how to connect to Data Warehouse using JRuby and then to execute a simple query using Sequel:
#!/usr/bin/env ruby
require 'rubygems'
require 'sequel'
require 'jdbc/dss'
Jdbc::DSS.load_driver
Java.com.gooddata.dss.jdbc.driver.DssDriver
# replace with your Data Warehouse instance:
dss_jdbc_url = 'jdbc:gdc:datawarehouse://secure.gooddata.com/gdc/datawarehouse/instances/[DW_ID]'
# replace with your GoodData platform login name:
username = 'joe.user@example.com'
# replace with your GoodData platform password:
password = 'MyPassword'
# example query
Sequel.connect dss_jdbc_url, :username => username, :password => password do |conn|
conn.run "CREATE TABLE IF NOT EXISTS my_first_table (id INT, value VARCHAR(255))"
conn.run "INSERT INTO my_first_table (id, value) VALUES (1, 'one')"
conn.run "INSERT INTO my_first_table (id, value) VALUES (2, 'two')"
conn.fetch "SELECT * FROM my_first_table WHERE id < ?", 3 do |row|
puts row
end
end
Data Warehouse is designed as a service for building data warehousing solutions and it is not expected to be used as an OLTP database. If you are looking for a way of exposing the data in Data Warehouse to your end users, consider pushing necessary data from Data Warehouse into either a GoodData workspace to deliver analytical dashboards or to your operational database that is optimized to be a backend of your end user facing application code.