Open Source SQL Parsers

This page summarizes the projects mentioned and recommended in the original post on dev.to

Our great sponsors
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • SaaSHub - Software Alternatives and Reviews
  • sqlparse

    A non-validating SQL parser module for Python

    Regular expressions is a popular approach to extract information from SQL statements. However, regular expressions quickly become too complex to handle common features like WITH, sub-queries, windows clauses, aliases and quotes. sqlparse is a popular python package that uses regular expressions to parse SQL.

  • parser

    A MySQL Compatible SQL Parser (by pingcap)

    Pingcap parser is a MySQL parser in Go.

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

  • sql-parser

    A validating SQL lexer and parser with a focus on MySQL dialect. (by phpmyadmin)

    SQL Parser in phpmyadmin is a validating SQL lexer and parser with a focus on MySQL dialect.

  • libpg_query

    C library for accessing the PostgreSQL parser outside of the server environment

    libpg_query extracts the parser (written in C) from the postgres project and packages it as a stand-alone library. This library is wrapped in other languages by other projects like:

  • pglast

    PostgreSQL Languages AST and statements prettifier: master branch covers PG10, v2 branch covers PG12, v3 covers PG13, v4 covers PG14, v5 covers PG15, v6 covers PG16

    Python: pglast

  • pg_query

    Ruby extension to parse, deparse and normalize SQL queries using the PostgreSQL query parser

    Ruby : pg_query

  • pg_query_go

    Go library to parse and normalize SQL queries using the PostgreSQL query parser

    Golang: pg_query_go

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

  • Apache Hive

    Apache Hive

    Apache Calcite is a popular parser/optimizer that is used in popular databases and query engines like Apache Hive, BlazingSQL and many others.

  • pgsql-parser

    PostgreSQL Query Parser for Node.js

    JS: psql-parser in Node and pg-query-emscripten in the browser

  • pg-query-emscripten

    Emscripten Port of pg_query to easily play with it in the browser

    JS: psql-parser in Node and pg-query-emscripten in the browser

  • pg_parse

    PostgreSQL parser for Rust that uses the actual PostgreSQL server source to parse SQL queries and return the internal PostgreSQL parse tree.

    Rust: pg_query.rs

  • queryparser

    Parsing and analysis of Vertica, Hive, and Presto SQL.

    queryparser implements Apache Hive, Presto/Trino and Vertica dialects.

  • zetasql

    ZetaSQL - Analyzer Framework for SQL

    zetasql implements BigQuery, Spanner, and Dataflow dialects.

  • mo-sql-parsing

    Let's make a SQL parser so we can provide a familiar interface to non-sql datastores!

    Python: mo-sql-parseing

  • JSqlParser

    JSqlParser parses an SQL statement and translate it into a hierarchy of Java classes. The generated hierarchy can be navigated using the Visitor Pattern

    JSQLParser can parse multiple SQL dialects like MySQL, Postgres and Oracle. The grammar can be modified to support other SQL dialects.

  • Apache Calcite

    Apache Calcite

    There are multiple projects that maintain parsers for popular open source databases like MySQL and Postgres. For other open source databases, the grammar can be extracted from the open-source project. For commercial databases, the only option is to reverse engineer the complete grammar. There are SQL parser/optimizer platforms like Apache Calcite that help to reduce the effort to implement the SQL dialect of your choice.

  • ANTLR

    ANTLR (ANother Tool for Language Recognition) is a powerful parser generator for reading, processing, executing, or translating structured text or binary files.

    An alternate approach is to implement the SQL grammar using parser generators like ANTLR. There are similar open source parser generators in other popular languages.

  • SaaSHub

    SaaSHub - Software Alternatives and Reviews. SaaSHub helps you find the best software and product alternatives

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts