Our take
- Activity
- 37
- Community
- 67
- Issues
- 31
- Pull requests
- 30
+0 stars in the last 30 days
- More contributors than 77% of the projects we track
- Slower to close issues than 100% of the projects we track
Project history
Daily GitHub snapshots since Oct 7, 2026. History covers stars and forks; health signals are not tracked historically.
Stars
4,022Forks
782Change since Nov 16, 2026: 0 stars·+1 forks
Overview
sqlparse turns SQL text into statements and token groups without checking whether the SQL is valid or enforcing a specific dialect. This makes it useful as a parsing layer for applications that need to handle SQL text, including vendor extensions or templates, rather than execute or validate queries.
It provides formatting and statement-splitting helpers alongside a traversable token tree. Python developers can use it directly or through the sqlformat command-line tool when building formatters, editors, linters, or query analysis utilities.
Key Features
- Split a SQL script into individual statements.
- Format SQL with options such as reindentation, keyword casing, comment stripping, and indentation width.
- Parse statements into tokens and grouped structures that can be traversed.
- Inspect statement types and nested constructs such as subqueries and
CASEexpressions. - Use the
sqlformatcommand-line tool to format input from a file or standard input. - Integrate SQL formatting into commits with the provided pre-commit hook.
- Process SQL without selecting a particular dialect or requiring the input to be valid.
Use Cases
- Python developers can add SQL formatting to editor integrations or development utilities without implementing tokenization themselves.
- Teams can standardize SQL layout in repositories using the formatter or pre-commit hook.
- Linters and query-analysis tools can traverse statements and token groups to build their own checks.
- Applications that process templated or vendor-specific SQL can tokenize text without first requiring dialect validation.
Getting Started
Install with pip install sqlparse. See the README for usage examples, command-line options, and documentation links.
Considerations
- This is a non-validating parser. It does not establish that SQL is syntactically valid or suitable for execution.
- The project makes no assumptions about a particular SQL dialect, so dialect-specific validation or semantic analysis must be handled separately.
- The maintainers note that the project is maintained in spare time, and issue or pull request responses may take a while.
Found this useful?
Share it with someone who would like sqlparse.