Simple DDL Parser is a Python library designed to parse SQL DDL (Data Definition Language) files from various dialects, including HQL, TSQL (MSSQL), Oracle, AWS Redshift, Snowflake, MySQL, and PostgreSQL. It extracts comprehensive information about database entities like tables, columns (types, defaults, primary keys), sequences, alters, and custom types into a JSON or Python dictionary format. The library is actively maintained with frequent releases, currently at version 1.13.0, and typically sees rapid updates with more than 12 releases per year.
pip install simple-ddl-parserVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to parse a DDL statement using the `DDLParser` class. It shows a basic table creation and an example of parsing an HQL statement with the `output_mode='hql'` argument to extract dialect-specific details like `EXTERNAL` or `LOCATION`.
Upgrade your Python environment to 3.9 or newer.
Update your code to expect `[''field'']` instead of `''('field')'` for bracketed arguments. Review custom parsing logic that might rely on older tokenization of `=` and `IN`.Adjust your code to handle the new output schema for PostgreSQL's `TIME ZONE` and BigQuery's `RANGE_BUCKETS` and `*_TRUNC` constructs.
Initialize the parser with `DDLParser(ddl_string, silent=False)` to force it to raise a `DDLParserError` on unparsable statements. Alternatively, inspect the output carefully for missing entities.
Ensure you are using a recent version of `simple-ddl-parser` (fix was included in `v0.26.0` and later). If the issue persists with other `IN` clauses, consider rewriting the `CHECK` statement using `OR` conditions or report an issue.
Simplify the problematic index definitions in your DDL for parsing, or update to the latest version as bug fixes are frequently released for such edge cases. Report specific DDL examples as GitHub issues if the problem persists.
Enable strict error reporting with `DDLParser(ddl_string, silent=False)` to get a more specific `DDLParserError`. Review the DDL for syntax that might not be fully supported by `simple-ddl-parser` or dialect-specific nuances.