Skip to content

Commit

Permalink
readme
Browse files Browse the repository at this point in the history
  • Loading branch information
mechatroner committed Feb 12, 2020
1 parent 1bc32fb commit 90c9773
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ Supported values: _"latin-1"_, _"utf-8"_

# RBQL (Rainbow Query Language) Description

RBQL is a technology which provides SQL-like language that supports _SELECT_ and _UPDATE_ queries with Python or JavaScript expressions.
RBQL is a technology for (not only) CSV files processing. It provides SQL-like language that supports SELECT queries with Python or JavaScript expressions.
RBQL is distributed with CLI apps, text editor plugins, Python and JS libraries and can work in web browsers.
RBQL core module is very generic and can process all kind of objects and record formats, but most popular RBQL implementation works with CSV files.

Expand Down Expand Up @@ -168,10 +168,10 @@ RBQL for CSV files provides the following variables which you can use in your qu
* _NF_
Variable type: **integer**
Description: Number of fields in the current record
* _a.name_, _b.Person_age_, ... _a.{good_alphanumeric_column_name}_
* _a.name_, _b.Person_age_, ... _a.{Good_alphanumeric_column_name}_
Variable type: **string**
Description: Value of the field referenced by it's "name". You can use this notation if the field in the first (header) CSV line has a "good" alphanumeric name
* _a["object id"]_, _a['9.12341234']_, _b["%$ !! 10 20"]_ ... _a["arbitrary column name!"]_
* _a["object id"]_, _a['9.12341234']_, _b["%$ !! 10 20"]_ ... _a["Arbitrary column name!"]_
Variable type: **string**
Description: Value of the field referenced by it's "name". You can use this notation to reference fields by arbitrary values in the first (header) CSV line, even when there is no header at all

Expand Down Expand Up @@ -238,6 +238,7 @@ You can define custom functions and/or import libraries in two special files:
* `select * where re.match(".*ab.*", a1) is not None` - select entries where first column has "ab" pattern
* `select a1, b1, b2 inner join ./countries.txt on a2 == b1 order by a1, a3` - example of join query
* `select MAX(a1), MIN(a1) where a.Name != 'John' group by a2, a3` - example of aggregate query
* `select *a1.split(':')` - Using Python3 unpack operator to split one column into many. Do not try this with other SQL engines!

#### With JavaScript expressions

Expand All @@ -248,6 +249,7 @@ You can define custom functions and/or import libraries in two special files:
* `select NR, *` - enumerate records, NR is 1-based
* `select a1, b1, b2 inner join ./countries.txt on a2 == b1 order by a1, a3` - example of join query
* `select MAX(a1), MIN(a1) where a.Name != 'John' group by a2, a3` - example of aggregate query
* `select ...a1.split(':')` - Using JS "destructuring assignment" syntax to split one column into many. Do not try this with other SQL engines!


### FAQ
Expand All @@ -262,7 +264,7 @@ And if you are doing math operation you can modify your query like this, example

#### How does RBQL work?

RBQL parses SQL-like user query, creates a new python or javascript worker module, then imports and executes it.
RBQL parses SQL-like user query, generates new Python or JavaScript code and executes it.

Explanation of simplified Python version of RBQL algorithm by example.
1. User enters the following query, which is stored as a string _Q_:
Expand Down Expand Up @@ -298,7 +300,7 @@ Explanation of simplified Python version of RBQL algorithm by example.
print ','.join([str(v) for v in out_fields])
```

6. RBQL runs the patched script against user's data file:
6. RBQL runs the patched script against user's data file (real RBQL implementation calls "exec" in Python or "eval" in JS):
```
./tmp_script.py < data.tsv > result.tsv
```
Expand All @@ -310,7 +312,6 @@ Adding support of TOP/LIMIT keywords is trivial and to support "ORDER BY" we can
### References

* [RBQL: Official Site](https://rbql.org/)
RBQL is integrated with Rainbow CSV extensions in [Vim](https://github.com/mechatroner/rainbow_csv), [VSCode](https://marketplace.visualstudio.com/items?itemName=mechatroner.rainbow-csv), [Sublime Text](https://packagecontrol.io/packages/rainbow_csv) editors.
* RBQL is integrated with Rainbow CSV extensions in [Vim](https://github.com/mechatroner/rainbow_csv), [VSCode](https://marketplace.visualstudio.com/items?itemName=mechatroner.rainbow-csv), [Sublime Text](https://packagecontrol.io/packages/rainbow_csv) and [Atom](https://atom.io/packages/rainbow-csv) editors.
* [RBQL in npm](https://www.npmjs.com/package/rbql): `$ npm install -g rbql`
* [RBQL in PyPI](https://pypi.org/project/rbql/): `$ pip install rbql`

0 comments on commit 90c9773

Please sign in to comment.