Interactive Yql
Switch branches/tags
Nothing to show
Pull request Compare This branch is 99 commits behind dgvncsz0f:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


iYQL – Interactive YQL

The purpose of this project is to implement a CLI (commend-line interface) for YQL. The goal is to implement something similar to databases like sqlite3 or mysql commend-line interfaces.

1. Input

There are two major modes of operation. The first one is the interactive one, which is started by default. Using libreadline, it reads one command at time, each command ending by ; (mandatory). This statement is parsed in order to determine which type of authentication is required — either none, two legged or three legged. After the proper oauth token is acquired, the query is sent to yql and the result is shown to the user.

The other mode is the batch mode, which queries are read either from stdin or from an argument. This is most useful for piping data into the program or using iyql to feed other programs in the unix pipeline.

2. Output

The idea is also parse the output and print it in a structured format, similar to what database interfaces do. However, the first release is planned to display the output as-is, and parsing and changing the output is scheduled for a second release.

3. Local and Remote

There will be local commands, that are useful to inspect the state of the program. Local commands will always be prefixed by the . character. For instance .whoami shows information about the oauth"token in use. These commands are processed locally and never sent to YQL. Everything not starting by `.’ is considered to be a valid YQL statement, parsed and sent to YQL engine.

4. Examples

4.1. Simple SELECT:

iyql> select * from where name="dsouza";

4.2. Local “.json()” function:

Transforms the results to JSON format:

iyql> select * from where name="dsouza" | .json();

4.3. Local “.tables()” function:

Transforms the results to a table-like format (similar to MySQL):

iyql> select guid,pubid from meme.posts where owner_guid="XYZXPTOETCXYZXPTOETC" | .tables();

4.4. Extense SELECT using “.tables()” function:

iyql> select guid,following,followers,name,title from where name in ("dsouza","julcirocha","meme") | .tables();

5. Installing

5.1. Install dependencies

Install the following dependencies using Cabal:

$ cabal install hoauth
$ cabal install haxml
$ cabal install test-framework-hunit

* “test-framework-hunit” is only needed if you want to execute “make test” before installing.

5.2. Compile and Install

$ make
$ sudo make install

* “make install” will copy the “iyql” binary to your /usr/local/bin directory.