How andialbrecht/sqlparse works
sqlparse is a non-validating SQL parsing library. The main workflow tokenizes SQL, splits it into statements, optionally groups tokens into a navigable syntax tree, and returns statements for inspection or formatting. Formatting uses configurable filters; the command-line tool reads SQL and invokes the same formatting API. The graph preserves the documented split, parse, tree-inspection, formatting, and CLI capabilities. Some internal links rely on the SOURCE INDEX or README; unsampled implementation details are not inferred.
Main entry points: formatter.py Format Options · filter_stack.py Filter Stack · __init__.py API Functions · lexer.py SQL Lexer
Components 16
Public API
- API Functions
sqlparse/__init__.py
Parsing Engine
- SQL Lexer
sqlparse/lexer.py - Keyword Rules
sqlparse/keywords.py - Statement Splitter
sqlparse/engine/statement_splitter.py - Token Grouping
sqlparse/engine/grouping.py - Filter Stack
sqlparse/engine/filter_stack.py
Token Model
- Token Types
sqlparse/tokens.py - SQL Token Tree
sqlparse/sql.py
Formatting
- Format Options
sqlparse/formatter.py - Reindent Filter
sqlparse/filters/reindent.py - Aligned Indent
sqlparse/filters/aligned_indent.py - Text Filters
sqlparse/filters/others.py - Token Filters
sqlparse/filters/tokens.py - Output Filters
sqlparse/filters/output.py
Command Line
- sqlformat CLI
sqlparse/cli.py
Other components
- SQL User
Connections 17
- SQL User → API Functions: submits SQL
README.md - API Functions → Filter Stack: parses and splits
sqlparse/__init__.py - Filter Stack → SQL Lexer: tokenizes
sqlparse/engine/filter_stack.py - SQL Lexer → Keyword Rules: uses rules
sqlparse/lexer.py - SQL Lexer → Token Types: emits types
sqlparse/lexer.py - Filter Stack → Statement Splitter: splits stream
sqlparse/engine/filter_stack.py - Filter Stack → Token Grouping: groups optionally
sqlparse/engine/filter_stack.py - Token Grouping → SQL Token Tree: builds groups
sqlparse/engine/grouping.py - SQL Token Tree → Token Types: uses types
sqlparse/sql.py - API Functions → Format Options: formats SQL
sqlparse/__init__.py - Format Options → Reindent Filter: configures filter
sqlparse/formatter.py - Format Options → Aligned Indent: configures filter
sqlparse/formatter.py - Format Options → Text Filters: configures filters
sqlparse/formatter.py - Format Options → Token Filters: configures filters
sqlparse/formatter.py - Format Options → Output Filters: configures filters
sqlparse/formatter.py - SQL User → sqlformat CLI: runs command
README.md - sqlformat CLI → API Functions: formats input
sqlparse/cli.py