skillfed

mo-sql-parsing

More SQL Parsing! Parse SQL into JSON parse tree

mo-sql-parsing v11.697.25301 204.4K downloads/30d#9,609 on PyPI294
Copyleft license MPL 2.0 AGING released

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

uv

uv add mo-sql-parsing

poetry

poetry add mo-sql-parsing

Installing 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

Development Status :: 5 - Production/StableLicense :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.15Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: SQLTopic :: Software Development :: LibrariesTopic :: Software Development :: Libraries :: Python Modules

Tags

sql parser jsonconvert sql to jsonsql query parsingsql ast generatorsql to json treeparse sql statementssql dialect parser
sql-parsingquery-translationjson-serialization

More Libraries packages