skillfed

pydbml

Python parser and builder for DBML

pydbml v1.2.1 94.7K downloads/30d#13,319 on PyPI139
Permissive license MIT Active released

What it is and what it does

PyDBML is a Python parser and builder for DBML, a human-readable markup language for defining database schemas. It reads DBML files or strings and constructs an in-memory representation of the schema as a Database object, allowing you to access tables, references, enums, and table groups programmatically. You can then generate SQL DDL statements from the parsed schema or regenerate DBML from modified objects.

The package is compliant with DBML v3.9.5 syntax and depends only on pyparsing for parsing. It's useful when you need to work with DBML schemas in Python code—reading them for documentation, validation, or transformation, or building schemas programmatically and exporting them as SQL or DBML.

Use it for:

  • Parse a DBML schema file and generate SQL DDL to create database tables.
  • Read DBML definitions and programmatically extract table and column metadata for documentation or tooling.
  • Build a database schema in code and export it as DBML or SQL for version control and collaboration.
  • Validate or transform DBML schemas by parsing, modifying, and regenerating them.
  • Integrate DBML schema definitions into Python-based database migration or ORM tools.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

PyDBML parses and generates DBML (Database Markup Language) schemas, converting between DBML syntax and SQL or back to DBML format.

Yes. PyDBML is actively maintained, has no known vulnerabilities, installs with minimal friction, and is permissively licensed. Install it if you need to parse or generate DBML schemas in Python—it's the standard tool for that task.

Install

pydbml on PyPI

pip

pip install pydbml

uv

uv add pydbml

poetry

poetry add pydbml

Installing pydbml

Before you install

Low install friction with a single runtime dependency (pyparsing). Active maintenance with a recent release in October 2025 and commits through April 2026.

License in practice

MIT license permits commercial and private use with minimal restrictions; suitable for most projects without licensing concerns.

Quickstart

from pydbml import PyDBML
from pathlib import Path

parsed = PyDBML(Path('schema.dbml'))
for table in parsed.tables:
    print(table.name)
print(parsed.sql)

Requires Python 3.8 or higher.

Verify before relying

  • Whether the parser handles all DBML v3.9.5 features or only a subset.
  • Performance characteristics when parsing large or complex schemas.

Package facts

License MIT (permissive)
Python support supports the current Python release (>=3.8)
Install friction low — pure-Python wheel
Runtime dependencies 1 — pyparsing
Maintenance actively maintained — 294 days since the last release
Last repo commit
First released
Downloads 94,653/month — #13,319 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: pydbml-1.2.1-py3-none-any.whl

Development Status :: 5 - Production/StableEnvironment :: ConsoleIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: PythonTopic :: DocumentationTopic :: Text Processing :: MarkupTopic :: Utilities

Tags

DBML parser pythondatabase schema markup languageparse DBML filesgenerate SQL from DBMLDBML to SQL converterdatabase schema definitionDBML syntax parser
schema-definitionmarkup-languagesql-generation

More Utilities packages