-
Notifications
You must be signed in to change notification settings - Fork 664
AlaSQL CLI
Mathias Rangel Wulff edited this page Nov 24, 2015
·
5 revisions
AlaSQL can be used in a console by installing it globally: npm install alasql -g
Usage:
alasql "sql-statement" [ params ] - Run SQL statement
alasql --file file.sql [ params ] - (or -f) Run SQL from file
alasql --version - (or -v) Echo AlaSQL version
Samples:
alasql 'select 2+2'
alasql 'select count(*) from txt()' < city.txt
alasql 'select * into xlsx("city.xlsx") from txt("city.txt")'
Examples:
Number of lines in text file with length more than 20 characters
alasql 'select value count(*) from txt("README.md") where length([0]) > 20'
Convert XLSX file to JSON
> alasql "SELECT * INTO json('my.json') from xlsx('cities.xlsx',{headers:true}) WHERE population > 20000000"
Simple calculator
> alasql 'VALUE OF SELECT 2*2'
4
?
will be replaced with the corresponding n'th argument so alasql "select ?+?" 10 20
corresponds to alasql select 10+20
> alasql "VALUE SELECT 20-?+?" 5 100
115
(To get value instead of a JSON you can prepend VALUE OF
to the SELECT
)
© 2014-2024, Andrey Gershun & Mathias Rangel Wulff
Please help improve the documentation by opening a PR on the wiki repo