iYQL – Interactive YQL
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.
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.1. Simple SELECT:
iyql> select * from meme.info where name="dsouza";
- Screenshot: 1-simple-select.png
4.2. Local “.json()” function:
Transforms the results to JSON format:
iyql> select * from meme.info where name="dsouza" | .json();
- Screenshot: 2-local-json-function.png
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();
- Screenshot: 3-local-tables-function.png
4.4. Extense SELECT using “.tables()” function:
iyql> select guid,following,followers,name,title from meme.info where name in ("dsouza","julcirocha","meme") | .tables();
- Screenshot: 4-extense-select.png
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.