Mode

This gem provides command line tools for interacting with the Mode Analytics APIs.

Install Mode

Mode requires Ruby 1.9 or JRuby 1.7 or newer

For the best performance and compatibility we recommend JRuby.

If you don't currently have a suitable ruby or aren't sure then follow these directions to install it before continuing.

gem install mode

Logging In

Before you use the mode gem you'll need to login.

The login process allows you to authorize the machine to connect via the API with the use of an API access token. The first time you use this command the it will look as follows:

$ mode 
Enter your Mode credentials:
Username: besquared
Password: 

No API tokens found, would you like to create a new token? [y/n] y

Choose a token name: Connector
Updated configuration at /Users/josh/.mode/config.yml

Adding Data Sources

Open the Mode configuration file in your favorite text editor (I'm using sublime text)

$ subl ~/.mode/config.yml

A sample data sources configuration is listed which you can copy to the bottom of your config file and modify:

data_sources:
  development:
    adapter: jdbc:postgresql
    host: localhost
    database: development
    username: postgres
    password:

  warehouse:
    adapter: jdbc:redshift
    host: hostname.redshift.amazonaws.com
    port: 5439
    database: dev
    username: 
    password: 

Database Drivers

If you're using JRuby then you can load JDBC drivers by copying the driver's jar files into Mode's drivers directory

Example for teradata:

cp terajdbc4.jar ~/mode/drivers
cp tdgssconfig.jar ~/mode/drivers

For ruby1.9+ you need to install the correct driver gem and libraries

# PostgreSQL
gem install pg

# Redshift
gem install sequel_redshift

# MySQL
gem install mysql2

# Oracle 9i+
gem install oci8

# SQL Server & Azure
gem install tiny_tds

# DB2
gem install ibm_db

Verifying your API and driver configuration

You can verify that your data sources are correct by using the verify command:

$ mode connect verify

Controlling the connector

Starting

$ mode connect start

Restarting

$ mode connect restart

Stopping

$ mode connect stop

Connector logging

The connect logs all its activity and errors to a log file that rotates weekly by default.

tail -f ~/.mode/log/mode.log