mo-sql-parsing
More SQL Parsing! Parse SQL into JSON parse tree
What it is and what it does
mo-sql-parsing converts SQL queries into JSON objects where each SQL clause becomes a named property. The parser originally targeted MySQL but now supports multiple database engines including SQLServer (with bracket identifiers) and BigQuery (with array syntax). It handles complex queries including subqueries, WITH clauses, window functions, CREATE/DROP/ALTER statements, and basic DML (INSERT/UPDATE/DELETE), with limited UDF support.
The package also works in reverse: you can generate SQL from a JSON parse tree using the format function. It offers multiple parsing modes—parse_mysql for double-quoted strings, parse_sqlserver for bracket identifiers, and options to customize NULL representation and function call format (simple operator vs. normalized). The output is designed to be JSON-serializable, making it suitable for downstream translation to other datastores or query engines.
Use it for:
- Translate SQL queries between different database systems by parsing to JSON and regenerating for the target dialect
- Build query analysis tools that inspect SQL structure programmatically via JSON representation
- Convert SQL to alternative query languages or intermediate representations for query optimization
- Validate or normalize SQL syntax by parsing and reformatting through the JSON layer
- Extract metadata from SQL (table names, column references, join conditions) by traversing the parse tree
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Parses SQL queries into JSON-serializable parse trees, and can generate SQL back from JSON, supporting multiple database flavors including MySQL, SQLServer, and BigQuery.
Yes, if you need to parse SQL into a structured, JSON-friendly format for cross-database translation or query analysis. The package is stable (Production/Stable status) with broad Python version support and no known vulnerabilities. The aging maintenance status (290 days since last release) is a minor concern for active development, but the repository remains responsive to issues. The MPL 2.0 copyleft license requires disclosure of modifications. Install friction is low.
Install
mo-sql-parsing on PyPI
pip
pip install mo-sql-parsinguv
uv add mo-sql-parsingpoetry
poetry add mo-sql-parsingInstalling mo-sql-parsing
Before you install
Low install friction with a pure-Python wheel and four lightweight runtime dependencies. Maintenance is aging—last release was 290 days ago—but the repository remains active with ongoing issue resolution and over 1200 tests covering most SQL dialects.
License in practice
Licensed under MPL 2.0 (copyleft). You must disclose source modifications and distribute under the same license if you modify the package; using it unmodified in a closed-source application is permitted.
Quickstart
pip install mo-sql-parsing
from mo_sql_parsing import parse
result = parse("select count(1) from jobs")
# Output: {'select': {'value': {'count': 1}}, 'from': 'jobs'}
Verify before relying
- Whether the parser handles all SQL edge cases in your specific database dialect without manual workarounds
- Performance characteristics when parsing very large or deeply nested queries
Package facts
| License | MPL 2.0 (copyleft) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 4 — mo-dots, mo-future, mo-imports, mo-parsing |
| Maintenance | aging — 290 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 204,381/month — #9,609 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: mo_sql_parsing-11.697.25301-py3-none-any.whl
Tags
More Libraries packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
python-dateutilProvides parsing, arithmetic, and recurrence…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
gw-dsl-parserConverts graphic-walker workflow definitions…
permissive · top 15,000 on PyPI
moz-sql-parserParses SQL queries into JSON-serializable parse…
copyleft · top 15,000 on PyPI
scim2-filter-parserParses SCIM 2.0 filter query strings into…
permissive · top 5,000 on PyPI
simple-ddl-parserParses SQL DDL statements and their dialect…
permissive · top 15,000 on PyPI
mo-parsingmo-parsing is a PEG parser generator that lets…
permissive · top 15,000 on PyPI
sqloxidesqloxide parses SQL queries into a typed…
permissive · top 15,000 on PyPI
ddlparseParses CREATE TABLE DDL statements from MySQL,…
permissive · top 15,000 on PyPI
sqlparsesqlparse tokenizes SQL text into a tree of…
permissive · top 1,000 on PyPI
sql-metadataParses SQL queries using sqlglot and extracts…
permissive · top 5,000 on PyPI
pglastParses PostgreSQL SQL statements into an…
copyleft · top 5,000 on PyPI