Skip to main content

sqlml-parser

sqlml-parser is a Python implementation of an SQL parser that effectively converts SQL statements into Abstract Syntax Trees (AST). By leveraging AST tree comparisons between two SQL queries, it becomes possible to achieve robust evaluation of text-to-SQL models.

Quick Start

Install

pip install sqlml-parser

Parser SQL

>> > from sqlml_parser.parser.mysql_parser import parser as mysql_parser
>> > mysql_parser.parse("select * from t")
Query(query_body=QuerySpecification(select=Select(distinct=False, select_items=[
    SingleColumn(expression=QualifiedNameReference(name=QualifiedName.of("*")))]),
                                    from_=Table(name=QualifiedName.of("t"), for_update=False), order_by=[], limit=0,
                                    offset=0, for_update=False, nowait_or_wait=False), order_by=[], limit=0, offset=0)
>> > from sqlml_parser.parser.oceanbase_parser import parser as oceanbase_parser
>> > oceanbase_parser.parse("select * from t")
Query(query_body=QuerySpecification(select=Select(distinct=False, select_items=[
    SingleColumn(expression=QualifiedNameReference(name=QualifiedName.of("*")))]),
                                    from_=Table(name=QualifiedName.of("t"), for_update=False), order_by=[], limit=0,
                                    offset=0, for_update=False, nowait_or_wait=False), order_by=[], limit=0, offset=0)
>> > from sqlml_parser.parser.odps_parser import parser as odps_parser
>> > odps_parser.parse("select * from t")
Query(query_body=QuerySpecification(select=Select(distinct=False, select_items=[
    SingleColumn(expression=QualifiedNameReference(name=QualifiedName.of("*")))]),
                                    from_=Table(name=QualifiedName.of("t"), for_update=False), order_by=[], limit=0,
                                    offset=0, for_update=False, nowait_or_wait=False), order_by=[], limit=0, offset=0)

Format SQL

>>> from sqlml_parser.format.formatter import format_sql
>>> from sqlml_parser.parser.mysql_parser import parser
>>> result=parser.parse("select * from t")
>>> format_sql(result)
'SELECT\n  *\nFROM\n  t'

Getting Started with SQL Parser Development

Document: SQL Parser Development Guide

Metadata

Release files for sqlml-parser 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sqlml-parser 0.0.1
File Size Uploaded
sqlml_parser-0.0.1.tar.gz 2.5 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for sqlml-parser 0.0.1
File Interpreter ABI Platform
sqlml_parser-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 5.2 MB

Release files / sqlml_parser-0.0.1.tar.gz

Download URL sqlml_parser-0.0.1.tar.gz
Size 2.5 MB
Tags Source
SHA-256 checksum
How to use checksums
b6367cf16c89dfe00c4dab9685b095b9690e4243524de7cb4f7566279b2e2d81
BLAKE2b-256 checksum
How to use checksums
05526bcf90d85c2e5aedd427ee8b7a5493c43287b6abc4eb2b3ebfb15ced57b5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.19

Release files / sqlml_parser-0.0.1-py3-none-any.whl

Download URL sqlml_parser-0.0.1-py3-none-any.whl
Size 2.7 MB
Tags Python 3
SHA-256 checksum
How to use checksums
fc58329faa556044122a23346d46fff706c8cf247d11587b541fa5c172e47741
BLAKE2b-256 checksum
How to use checksums
b9aad58354def4dca726f12e4853dde1d9e3a22baa5933510d6a6129871196f4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.19

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page