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

sql-parser-ast

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sql-parser-ast

Parses SQL into Abstract Syntax Tree (AST)

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

SQL Parser AST

Uses sql-parser-cst to parse SQL first into Concrete Syntax Tree (CST) and then converts the result to Abstract Syntax Tree (AST).

Synopsis

import { parse } from "sql-parser-ast";

parse("SELECT * FROM customer WHERE age > 10", { dialect: "sqlite" });

The parse() function returns the following AST:

{
  "type": "program",
  "statements": [
    {
      "type": "select_stmt",
      "columns": [{ "type": "all_columns" }],
      "from": {
        "type": "identifier",
        "name": "customer"
      },
      "where": {
        "type": "binary_expr",
        "left": {
          "type": "identifier",
          "name": "age"
        },
        "operator": ">",
        "right": {
          "type": "number_literal",
          "value": 10
        }
      }
    }
  ]
}

For now it takes the exact same parameters as sql-parser-cst. But the includeSpaces, includeNewlines, includeComments options have no effect.

Development status

This project is still in very early stages of development.

It supports a fair amount of SQLite syntax, but a lot of stuff is still missing.

Don't use it in production.

FAQs

Package last updated on 21 Feb 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