Skip to main content

A sql parser which support mysql, oceanbase and odps

Project description

sqlgpt-parser

sqlgpt-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

pip install sqlgpt-parser
>>> from sql_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 sql_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 sql_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)

Getting Started with SQL Parser Development

English Document: SQL Parser Development Guide 中文文档:SQL Parser 开发指南

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sqlgpt_parser-0.0.1a0.tar.gz (2.5 MB view details)

Uploaded Source

Built Distribution

sqlgpt_parser-0.0.1a0-py3-none-any.whl (2.6 MB view details)

Uploaded Python 3

File details

Details for the file sqlgpt_parser-0.0.1a0.tar.gz.

File metadata

  • Download URL: sqlgpt_parser-0.0.1a0.tar.gz
  • Upload date:
  • Size: 2.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for sqlgpt_parser-0.0.1a0.tar.gz
Algorithm Hash digest
SHA256 68beaec02330ae31c8fcd4c1d06bba77a7946f2e97658176b823f8f5fa901ce8
MD5 0dd16424bdb32cd7d74802d8cb0b1ea1
BLAKE2b-256 5405cfc84f97db410c8087882fba7ecc73e4dc4d953bd551fb37e311faa60a85

See more details on using hashes here.

File details

Details for the file sqlgpt_parser-0.0.1a0-py3-none-any.whl.

File metadata

File hashes

Hashes for sqlgpt_parser-0.0.1a0-py3-none-any.whl
Algorithm Hash digest
SHA256 fb2d40bbbb3338149b4383d47e87cdd63c48ce02098af2eccd4a0936e2df6980
MD5 5a86e6fac6170b7eea0e1d02d2e7f3a6
BLAKE2b-256 11a663bf68be23a2bdf26a80533201fc24506185157d99200f7140b9374dbffd

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page