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

@florajs/sql-parser

Package Overview
Dependencies
Maintainers
3
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@florajs/sql-parser

Parse SQL (select) statements into abstract syntax tree (AST) and convert ASTs back to SQL.

  • 3.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
3
Created
Source

@florajs/sql-parser

NPM version NPM downloads

Parse simple SQL statements into an abstract syntax tree (AST) and convert it back to SQL.

Usage

Create AST for SQL statement

const { Parser } = require('@florajs/sql-parser');
const parser = new Parser();
const ast = parser.parse('SELECT * FROM t');

console.log(ast);

Convert AST back to SQL

const { Parser } = require('@florajs/sql-parser');
const ast = (new Parser()).parse('SELECT * FROM t');
const toSQL = require('@florajs/sql-parser').util.astToSQL;

console.log(toSQL(ast));

The generated SQL is ANSI SQL compliant. To run those queries on MySQL, make sure you set correct SQL mode

SET SESSION sql_mode = 'ANSI';

before running any query.

Acknowledgement

This project is based on the SQL parser extracted from Alibaba's nquery module.

License

GPL-2.0

Keywords

FAQs

Package last updated on 03 Aug 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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