Registry / database / pydbml

pydbml

JSON →
library1.2.1pypypi✓ verified 85d ago

PyDBML is a Python library for parsing and building DBML (Database Markup Language) files. It allows developers to convert DBML definitions into SQL DDL statements and vice-versa, facilitating database schema design and management. The current version is 1.2.1, and the project maintains an active release cadence with regular bug fixes and feature enhancements.

pip install pydbml
INSTALL
IMPORT
SIG · PYDBML
P
pydbml
databasepythonv1.2.1
Install
1.7s avg
Import
Disk
17MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.2.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 19.3MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 1.7s · import 0.000s · 20MB
17MB installed
● package 17MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Database
from pydbml import Database
from pydbml import parse
PyDBML
from pydbml import PyDBML
parser
from pydbml import parser

This quickstart demonstrates how to parse a DBML string using `pydbml.parse` and then render the parsed object to SQL DDL and back to DBML format.

from pydbml import parse # Define a DBML string dbml_content = """ Project "MyProject" { database_type: 'PostgreSQL' Note: 'A simple example project' } Table "users" { id int [pk, increment] username varchar [unique, not null] email varchar [unique] created_at timestamp [default: `now()`] } Table "posts" { id int [pk, increment] title varchar [not null] content text user_id int [ref: > users.id] created_at timestamp [default: `now()`] } """ # Parse the DBML content try: parsed_dbml = parse(dbml_content) print("DBML parsed successfully.") # Render to SQL DDL sql_output = parsed_dbml.sql() print("\n--- Generated SQL ---") print(sql_output) # Optionally, render back to DBML (can differ slightly in formatting) dbml_output = parsed_dbml.dbml() print("\n--- Generated DBML (re-rendered) ---") print(dbml_output) except Exception as e: print(f"An error occurred during parsing or rendering: {e}")
Debug
Known issues
breakingUnicode characters in identifiers (e.g., table or column names) are temporarily disabled starting from v1.2.0 due to performance considerations. DBML files using them will fail to parse.
fix
Avoid using unicode characters in identifiers in your DBML schemas. If this functionality is critical and you accept potential performance impacts, you may need to downgrade to a version prior to 1.2.0.
affects: >=1.2.0
gotchaSQL rendering in versions prior to 1.2.1 might incorrectly omit quotes for string default values or ignore falsy default values (e.g., 0, false) entirely.
fix
Upgrade to `pydbml 1.2.1` or newer to ensure correct SQL rendering of string and falsy default values in your generated DDL.
affects: <1.2.1
gotchaThe SQL and DBML rendering engine was significantly rewritten in v1.1.0 to support external renderers. If you rely on exact output formatting from versions older than 1.1.0, verify generated SQL/DBML after upgrading.
fix
Review the generated SQL/DBML output after upgrading from versions older than 1.1.0 to ensure compatibility with your existing tooling or expectations, as subtle formatting or feature interpretations may have changed.
affects: >=1.1.0
Upgrade
Version history
1.2.1latest on PyPI · released Oct 24, 2025
Audit
Dependencies

No dependency data recorded yet.

Agent activity
12 hits · last 30 days
node
10
OpenAI (training)
1
Resources
pydbml — pip install pydbml · libregistry