/databox-ruby-sql

SQL to Databox with Databox Ruby Gem

Primary LanguageRubyMIT LicenseMIT

SQL → Databox with Databox Ruby Gem

How to quickly stream data from PostgreSQL to Databox with Databox Ruby Gem?

databox_demo.gif

Example

This example contains example on how to create PostgreSQL database that will hold OPEC oil prices. When new price is inserted into prices table PostgreSQL triggers NOTIFY and streamer.rb LISTENs and sends data to Databox.

Steps to get you going...

First create new .env in current project folder with your DATABOX_PUSH_TOKEN.

Create new database, start PostgreSQL daemon and setup new database:

initdb db/pg-data -E utf8;
postgres -D db/pg-data
rake db:setup

Start streamer that will LISTEN to inserts and push KPIs to Databox.

./streamer.rb

Open another terminal / session and run following task that will import couple of prices.

rake prices:import

For playing with data you can load IRB session:

irb -r./boot.rb
Price.create date:DateTime.now, volume:100
Price.import Price.all_from_ws

Author