Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

simple-sql-parser

Package Overview
Dependencies
Maintainers
2
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simple-sql-parser - npm Package Compare versions

Comparing version 0.0.5 to 1.0.0

example.html

76

package.json
{
"name": "simple-sql-parser",
"description": "Javascript library to parse CRUD (Create Retrieve Update Delete) SQL queries.",
"keywords": [
"sql",
"parser"
],
"license": "MIT",
"version": "0.0.5",
"author": "dsferruzza",
"contributors": [
{
"name": "David Sferruzza",
"email": "david.sferruzza@gmail.com"
},
{
"name": "RienNeVaPlus"
}
],
"private": false,
"repository": {
"type":"git",
"url":"https://github.com/RienNeVaPlus/sqlParser.js"
},
"main": "sqlParser.js",
"engines": {
"node": ">=0.10.5"
},
"dependencies":{
}
}
"name": "simple-sql-parser",
"description": "Javascript library to parse CRUD (Create Retrieve Update Delete) SQL queries.",
"version": "1.0.0",
"main": "simpleSqlParser.js",
"keywords": [
"sql",
"parse",
"ast"
],
"author": {
"name": "David Sferruzza",
"email": "david.sferruzza@gmail.com",
"url": "https://github.com/dsferruzza"
},
"contributors": [
{
"name": "RienNeVaPlus",
"url": "https://github.com/RienNeVaPlus"
}
],
"maintainers": [
{
"name": "David Sferruzza",
"email": "david.sferruzza@gmail.com",
"url": "https://github.com/dsferruzza"
}
],
"bugs": {
"url": "https://github.com/dsferruzza/simpleSqlParser/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/dsferruzza/simpleSqlParser.git"
},
"license": "MIT",
"homepage": "https://github.com/dsferruzza/simpleSqlParser",
"devDependencies": {
"grunt": "*",
"grunt-contrib-qunit": "*",
"grunt-contrib-jshint": "*",
"grunt-contrib-watch": "*"
},
"scripts": {
"test": "grunt"
}
}

@@ -1,42 +0,48 @@

sqlParser.js
============
simpleSqlParser
===============
Node.js Javascript library to parse CRUD (Create Retrieve Update Delete) SQL queries.
Javascript library to parse CRUD (Create Retrieve Update Delete) SQL queries.
Note: this is a Fork of https://github.com/dsferruzza/sqlParser.js
## How to use
## How to install
### From browser
Import the JS file in your page:
```html
<script src="simpleSqlParser.js"></script>
```
npm install simple-sql-parser
```
## How to use
### From Node.js
Require the parser:
Import the JS module in your app:
```js
var sqlParser = require('simple-sql-parser');
var simpleSqlParser = require('./simpleSqlParser.js');
```
Parse a query:
### Parse a query:
```js
var statement = 'SELECT * FROM table WHERE field = value';
var result = sqlParser(statement);
console.log(result);
var ast = simpleSqlParser.sql2ast('your SQL query');
console.log(ast);
```
## Result
### Create a query from AST:
```js
{
SELECT: [ '*' ],
FROM: [ 'table' ],
WHERE: { operator: '=', left: 'field', right: 'value' }
}
var query = simpleSqlParser.ast2sql(ast);
console.log(query);
```
*AST means Abstract Syntax Tree.*
## Examples
* See `example.html` (open brower's console)
* Have a look to the unit tests `tests/tests.js` to see what's possible
## Notes
sqlParser.js only supports these queries:
simpleSqlParser only supports these queries:
* SELECT

@@ -47,7 +53,7 @@ * INSERT

sqlParser.js **is not a full SQL parser!**
simpleSqlParser **is not a full SQL parser!**
It only support few SQL mechanisms and keywords.
Feel free to make a pull request/issue.
*sqlParser.js was made for @GestionAIR*
*simpleSqlParser was made for @GestionAIR*

@@ -54,0 +60,0 @@ ## License

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc