--- id: moz-sql-parser version: "4.40.21126" license: MPL 2.0 license_treatment: copyleft maintenance: aging --- # moz-sql-parser — Extract Parse Tree from SQL License: copyleft · Maintenance: aging · Downloads: 111.4K/mo ## What it is and what it does Moz SQL Parser converts SQL SELECT queries into JSON-serializable parse trees, where each SQL clause becomes a named object property and expressions are represented as operation-parameter pairs. It also provides a formatter to generate SQL from JSON objects, though that feature remains incomplete. The parser originally targeted MySQL but has expanded to other vendors; it handles basic queries, subqueries, WITH clauses, and window functions, but does not support UPDATE or INSERT statements or provide data access tools. The package is designed to let non-SQL datastores expose a familiar SQL interface to users, with the expectation that developers will convert the resulting JSON parse trees into native queries for their backend. It has no runtime dependencies, making installation straightforward, but the codebase is aging—the latest release is from May 2021 and maintenance appears minimal despite recent repository activity. Use it for: - Convert SQL queries to JSON for analysis, validation, or transformation in a custom query engine or datastore adapter. - Build a SQL-to-native-query translator that accepts SQL input and generates backend-specific queries from the parse tree. - Analyze SQL query structure programmatically to extract table names, columns, or filter conditions. - Provide a SQL interface to non-relational datastores by parsing user queries and mapping them to native APIs. - Generate SQL statements from JSON configuration objects for dynamic query construction. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Parses SQL queries into JSON-serializable parse trees, and can generate SQL from JSON objects, supporting basic SELECT queries with clauses like WHERE, ORDER BY, and window functions. Yes, if you need basic SQL parsing to JSON and can tolerate an aging codebase. The package has no dependencies, handles common SELECT patterns, and has been stable for years. However, install only if you do not require support for advanced SQL dialects or expect active maintenance; the latest release is from May 2021 and the project is classified as aging. The copyleft MPL 2.0 license requires source disclosure if you modify and redistribute. ## Install pip install moz-sql-parser uv add moz-sql-parser poetry add moz-sql-parser ## Installing moz-sql-parser Before you install: High install friction: the package has not been updated since May 2021 and is classified as aging. The last commit was in October 2025, but the latest release is nearly five years old, suggesting maintenance is minimal or stalled. License in practice: Licensed under Mozilla Public License 2.0 (MPL 2.0), a copyleft license. You must disclose source code modifications and distribute under the same license if you modify and distribute the package; this may constrain commercial or proprietary use. Quickstart: from moz_sql_parser import parse import json result = parse("select a, b from jobs where a > b") print(json.dumps(result)) Python recursion limit may need adjustment for large or deeply nested SQL queries; the default limit may be insufficient. Verify before relying: - Whether the parser handles modern SQL dialects (BigQuery, Redshift, etc.) beyond basic SELECT—the description notes these are still missing. - Current state of test coverage and whether the tests mentioned have been maintained or expanded. - Whether the formatter (SQL generation from JSON) is production-ready or remains incomplete. ## Package facts - License: MPL 2.0 (copyleft) - Python support: unspecified - Install friction: high - Maintenance: aging - Downloads: 111.4K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags sql parser to json, parse sql queries, sql to parse tree, sql query analysis, convert sql to json, sql syntax parsing, query tree extraction, sql-parsing, query-analysis, json-serialization [View on SkillFed](https://skillfed.io/packages/moz-sql-parser) · [View on PyPI](https://pypi.org/project/moz-sql-parser/)