Meet AlaSQL, a speedy SQL database for JavaScript

Share
  • January 15, 2019

Introducing a young interesting project, AlaSQL, an open source SQL database for JavaScript.

AlaSQL focuses on query speed and data source flexibility for both relational data and schemaless data. What’s more, it works in the web browser, Node.js, and mobile apps.

So what does AlaSQL bring to the ecosystem? Here are some of its most interesting characteristics:

  • Fast in-memory SQL data processing for BI and ERP applications on fat clients
  • Easy ETL and options for persistence by data import/manipulation/export of several formats

Let’s have a closer look at its main features and how you can give it a try.

The highlights

Here are some of the most interesting features of AlaSQL:

Traditional SQL – Use “good old” SQL on your data with multiple levels of: JOINVIEWGROUP BYUNIONPRIMARY KEYANYALLINROLLUP()CUBE()GROUPING SETS()CROSS APPLYOUTER APPLYWITH SELECT, and subqueries. See the extensive list here.

User-Defined Functions in your SQL – You can use all benefits of SQL and JavaScript together by defining your own custom functions.

Compiled statements and functions – See all the info on this feature in the wiki.

SELECT against your JavaScript data – Group your JavaScript array of objects by field and count number of records in each group.

JavaScript Sugar – AlaSQL extends “good old” SQL to make it closer to JavaScript. The “sugar” includes:

  • Write Json objects – {a:'1',b:@['1','2','3']}
  • Acesss object propertires – obj->property->subproperty
  • Access Ooject and arrays elements – obj->(a*1)
  • Access JavaScript functions – obj->valueOf()
  • Format query output with SELECT VALUE, ROW, COLUMN, MATRIX
  • ES5 multiline SQL with var SQL = function(){/*SELECT 'MY MULTILINE SQL'*/} and pass instead of SQL string (will not work if you compress your code)

Read and write Excel and raw data files – You can import from and export to CSV, TAB, TXT, and JSON files. File extensions can be omitted. Calls to files will always be asynchronous so multi-file queries should be chained.

Read SQLite database files – AlaSQL can read (but not write) SQLite data files using SQL.js library. sql.js calls will always be asynchronous.

AlaSQL works in the console – CLI – The node module ships with an alasql command-line tool.

Head over to the GitHub repo to check out all the detailed features and examples.

SEE ALSO: SQLDelight 1.0 arrives with a complete rework

Getting started

You can install AlaSQL by running:

npm install --save alasql      # node
bower install --save alasql    # bower
npm install -g alasql          # global installation for command line tools

For the browser, you need to include alasql.min.js.

See the ‘getting started‘ guide for all the relevant information.

The post Meet AlaSQL, a speedy SQL database for JavaScript appeared first on JAXenter.

Source : JAXenter