You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 15, 2021. It is now read-only.
[](https://github.com/codeschool/sqlite-parser/)
6
6
[](https://github.com/codeschool/sqlite-parser/blob/master/LICENSE)
7
7
8
-
This library parses SQLite queries, using JavaScript, and generates
9
-
_abstract syntax tree_ (AST) representations of the input strings. A
10
-
syntax error is produced if an AST cannot be generated.
8
+
This JavaScript library parses SQLite queries to generate
9
+
_abstract syntax tree_ (AST) representations of the parsed statements.
**This parser is written against the [SQLite 3 spec](https://www.sqlite.org/lang.html).**
13
16
@@ -17,25 +20,22 @@ syntax error is produced if an AST cannot be generated.
17
20
npm install sqlite-parser
18
21
```
19
22
20
-
### Beta Version Available
23
+
### Install as a global module
21
24
22
-
If you want the latest and greatest, install the _beta_ version of the parser (currently [v1.0.0-beta](https://github.com/codeschool/sqlite-parser/releases/tag/v1.0.0-beta)) with loads of new features and fixes.
25
+
Use the command-line interface of the parser by installing it as a global module.
26
+
The `sqlite-parser` command is then available to use to parse input SQL files and
27
+
write the results to stdout or a JSON file. Additional usage
28
+
instructions and options available through `sqlite-parser --help`.
23
29
24
30
```
25
-
npm install sqlite-parser@beta
31
+
npm i -g sqlite-parser
26
32
```
27
33
28
-
## Demo
29
-
30
-
There is an interactive demo of the parser hosted
31
-
[at this location](http://codeschool.github.io/sqlite-parser/demo/). You
32
-
can run a copy of the demo on your local machine by cloning this repository
33
-
and then using the command `grunt live`.
34
-
35
-
## Usage
34
+
## Basic Usage
36
35
37
-
The library exposes a function that accepts two arguments: a string
38
-
containing SQL to parse and a callback function.
36
+
The library exposes a function that accepts two arguments: a string containing
37
+
SQL to parse and a callback function. If an AST cannot be generated from the
38
+
input string then a descriptive error is generated.
39
39
40
40
If invoked without a callback function the parser will runs synchronously and
41
41
return the resulting AST or throw an error if one occurs.
@@ -50,14 +50,14 @@ console.log(ast);
50
50
// async
51
51
sqliteParser(query, function (err, ast) {
52
52
if (err) {
53
-
console.log(err);
53
+
console.error(err);
54
54
return;
55
55
}
56
56
console.log(ast);
57
57
});
58
58
```
59
59
60
-
###Use parser on Node streams *experimental*
60
+
## Use parser on Node streams *(experimental)*
61
61
62
62
This library also includes *experimental* support as a
63
63
[stream transform](https://nodejs.org/api/stream.html) that can accept a
0 commit comments