-
Notifications
You must be signed in to change notification settings - Fork 664
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
38 changed files
with
925 additions
and
708 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ | |
test/res* | ||
node_modules/ | ||
npm-debug.log | ||
|
||
site/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,5 +11,5 @@ node_js: | |
- "4" | ||
- "0.12" | ||
|
||
before_install: | ||
- npm install -g alasql | ||
script: npm run test:only && npm test | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# How to Contribute to the AlaSQL project | ||
|
||
Thank you very much or the your intentions! AlaSQL project still has a lot of thing to be improved, and your help is very appreciated! | ||
|
||
You can read these materials before to start: | ||
|
||
* [How to Contribute to Open-Source](https://guides.github.com/activities/contributing-to-open-source/) | ||
* [How to setup AlaSQL development environment](https://github.com/agershun/alasql/wiki#development) | ||
|
||
We have many things to improve: | ||
* [issues and bugs](https://github.com/agershun/alasql/issues) | ||
* [wiki documentation](https://github.com/agershun/alasql/wiki) | ||
* code refactoring and documenting | ||
* import-export functions | ||
* examples | ||
* [alasql.org web site](https://github.com/agershun/alasql-org) | ||
|
||
You can choose any of these areas or issues, related to your needs for other projects. | ||
|
||
Thank you! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ _Got a question? Ask on [Stack Overflow](http://stackoverflow.com/questions/ask? | |
|
||
# AlaSQL | ||
|
||
<a href="http://alasql.org"><img src="https://cloud.githubusercontent.com/assets/1063454/13632161/9fd9cd08-e5e8-11e5-98cc-dca251e7b427.png" align="left" alt="AlaSQL logo" width="82" height="82"/></a> | ||
<a href="http://alasql.org"><img src="https://cloud.githubusercontent.com/assets/1063454/14003945/d6e56888-f156-11e5-95b9-3035a2538ae8.png" align="left" alt="AlaSQL logo" width="82" height="82"/></a> | ||
|
||
_( [à la](http://en.wiktionary.org/wiki/%C3%A0_la) [SQL](http://en.wikipedia.org/wiki/SQL) ) [ælæ ɛskju:ɛl]_ - AlaSQL is an open source SQL database for Javascript with a strong focus on query speed and datasource flexibility for relational data, schemaless data, and graph data. It works in your browser, Node.js, IO.js and Cordova. | ||
|
||
|
@@ -145,7 +145,7 @@ When you feel you got the grip you can check out the wiki section about [data ma | |
The project has never received any funding and is based on unpaid voluntary work: [We really (really) love pull requests](https://github.com/agershun/alasql/blob/develop/CONTRIBUTING.md) | ||
|
||
|
||
AlaSQL project is very young and still in active development phase, therefore it <s>may</s> have [bugs](https://github.com/agershun/alasql/labels/Bug). Please, submit any bugs and suggestions [as an issue](https://github.com/agershun/alasql/issues/new). AlaSQL uses [Semantic Versioning](http://semver.org/) so please note that major version is zero (0.y.z) and the API can not be considered 100% stable. Consider this before using the library in production. | ||
AlaSQL project is very young and still in active development phase, therefore it <s>may</s> have [bugs](https://github.com/agershun/alasql/labels/%21%20Bug). Please, submit any bugs and suggestions [as an issue](https://github.com/agershun/alasql/issues/new). AlaSQL uses [Semantic Versioning](http://semver.org/) so please note that major version is zero (0.y.z) and the API can not be considered 100% stable. Consider this before using the library in production. | ||
|
||
Please checkout the [limitations of the library](https://github.com/agershun/alasql#limitations) | ||
|
||
|
@@ -644,4 +644,7 @@ and other people for useful tools, which make our work much easier. | |
---- | ||
© 2014-2015, Andrey Gershun ([email protected]) & M. Rangel Wulff ([email protected]) | ||
<a href="http://alasql.org"><img src="https://cloud.githubusercontent.com/assets/1063454/14003946/d6e5c076-f156-11e5-8238-e62d2a8d20dc.png" align="right" alt="AlaSQL logo" width="82" height="82"/></a> | ||
© 2014-2016, Andrey Gershun ([email protected]) & M. Rangel Wulff ([email protected]) | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
#!/usr/bin/env node | ||
// | ||
// Command line interface for Alasql | ||
// Version: 0.2.2 | ||
// Date: 28.07.2015 | ||
// (c) 2014-2015, Andrey Gershun & M. Rangel Wulff | ||
// | ||
|
||
var alasql = require('alasql'); | ||
var path = require('path'); | ||
var fs = require('fs'); | ||
var yargs = require('yargs') | ||
.demand(1) | ||
.strict() | ||
.usage('AlaSQL command-line utility (version '+alasql.version+')\n\nUsage: $0 [options] [sql] [params]') | ||
|
||
.example('$0 "sql-statement"', 'Run SQL statement and output result as JSON') | ||
.example('') | ||
.example('$0 \'value of select 2+?\' 40', 'Outputs 42') | ||
.example('') | ||
.example('$0 \'select count(*) from txt()\' < city.txt', 'Count lines in city.txt') | ||
.example('') | ||
.example('$0 \'select * into xlsx("city.xlsx") from txt("city.txt")\'', 'Convert from txt to xlsx') | ||
.example('') | ||
.example('$0 --file file.sql France 1960', 'Run SQL from file with 2 parameters') | ||
|
||
.version('v', 'Echo AlaSQL version', alasql.version) | ||
.alias('v', 'version') | ||
|
||
.boolean('m') | ||
.describe('m', 'Minify json output') | ||
.alias('m', 'minify') | ||
|
||
.describe('f', 'Load SQL from file') | ||
.alias('f', 'file') | ||
.nargs('f', 1) | ||
.normalize('f') | ||
|
||
.help('h') | ||
.alias('h', 'help') | ||
|
||
.epilog('\nMore information about the library: www.alasql.org') | ||
var argv = yargs.argv; | ||
var sql = ''; | ||
var params = []; | ||
|
||
|
||
if(argv.v) { | ||
console.log(alasql.version); | ||
process.exit(0); | ||
} | ||
|
||
if(argv.f) { | ||
if (!fs.existsSync(argv.f)) { | ||
console.log('Error: file not found'); | ||
process.exit(1); | ||
} | ||
|
||
if (isDirectory(argv.f)) { | ||
console.log('Error: file expected but directory found'); | ||
process.exit(1); | ||
} | ||
|
||
sql = fs.readFileSync(argv.f, 'utf8').toString(); | ||
} else { | ||
sql = argv._.shift() || ''; | ||
} | ||
|
||
params = argv._; | ||
|
||
if(0===sql.trim().length){ | ||
yargs.showHelp(); | ||
process.exit(1); | ||
} | ||
|
||
for(var i=1;i<params.length;i++) { | ||
var a = params[i]; | ||
if(a[0] !== '"' && a[0] !== "'") { | ||
if(+a == a){ // jshint ignore:line | ||
params[i] = +a; | ||
} | ||
} | ||
} | ||
|
||
alasql.promise(sql,params) | ||
.then(function(res){ | ||
if(!alasql.options.stdout){ | ||
console.log(formatOutput(res)); | ||
} | ||
process.exit(0); | ||
}).catch(function(err){ | ||
console.log(formatOutput({error:err})); | ||
process.exit(1); | ||
}); | ||
|
||
|
||
/** | ||
* Is a Directory | ||
* | ||
* @param {String} filePath | ||
* @returns {Boolean} | ||
*/ | ||
function isDirectory(filePath){ | ||
var isDir = false; | ||
try { | ||
var absolutePath = path.resolve(filePath); | ||
isDir = fs.lstatSync(absolutePath).isDirectory(); | ||
} catch (e) { | ||
isDir = e.code === 'ENOENT'; | ||
} | ||
return isDir; | ||
} | ||
|
||
|
||
/** | ||
* Format output | ||
* | ||
* @param {Object} Object to be formatted according to -p flag | ||
* @returns {JSON string} | ||
*/ | ||
function formatOutput(obj){ | ||
if(argv.m){ | ||
return JSON.stringify(obj); | ||
} | ||
return JSON.stringify(obj, null, 2); | ||
} | ||
|
||
|
||
|
Oops, something went wrong.