{"id":14065656,"url":"https://github.com/Vanderhoof/PyDBML","last_synced_at":"2025-07-29T21:32:36.619Z","repository":{"id":39665875,"uuid":"255815502","full_name":"Vanderhoof/PyDBML","owner":"Vanderhoof","description":"DBML parser and builder for Python","archived":false,"fork":false,"pushed_at":"2025-03-12T11:52:39.000Z","size":340,"stargazers_count":123,"open_issues_count":6,"forks_count":16,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-07-27T11:24:47.028Z","etag":null,"topics":["dbml","parser","python","python3","sql"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Vanderhoof.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-04-15T05:36:52.000Z","updated_at":"2025-07-10T20:30:48.000Z","dependencies_parsed_at":"2023-02-15T18:31:39.217Z","dependency_job_id":"5549ecd3-7701-4276-9dad-c3defa810cc9","html_url":"https://github.com/Vanderhoof/PyDBML","commit_stats":{"total_commits":134,"total_committers":4,"mean_commits":33.5,"dds":"0.24626865671641796","last_synced_commit":"1dc5670667ed87bf4702cfad72cf831a0c1bb5f7"},"previous_names":[],"tags_count":29,"template":false,"template_full_name":null,"purl":"pkg:github/Vanderhoof/PyDBML","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Vanderhoof%2FPyDBML","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Vanderhoof%2FPyDBML/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Vanderhoof%2FPyDBML/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Vanderhoof%2FPyDBML/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Vanderhoof","download_url":"https://codeload.github.com/Vanderhoof/PyDBML/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Vanderhoof%2FPyDBML/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267763542,"owners_count":24140824,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-29T02:00:12.549Z","response_time":2574,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dbml","parser","python","python3","sql"],"created_at":"2024-08-13T07:04:37.168Z","updated_at":"2025-07-29T21:32:36.607Z","avatar_url":"https://github.com/Vanderhoof.png","language":"Python","readme":"[![](https://img.shields.io/pypi/v/pydbml.svg)](https://pypi.org/project/pydbml/) [![](https://img.shields.io/pypi/dm/pydbml.svg)](https://pypi.org/project/pydbml/)  [![](https://img.shields.io/github/v/tag/Vanderhoof/PyDBML.svg?label=GitHub)](https://github.com/Vanderhoof/PyDBML) ![](coverage.svg)\n\n# DBML parser for Python\n\n*Compliant with DBML **v3.9.5** syntax*\n\nPyDBML is a Python parser and builder for [DBML](https://www.dbml.org) syntax. \n\n\u003e The project was rewritten in May 2022, the new version 1.0.0 is not compatible with versions 0.x.x. See details in [Upgrading to PyDBML 1.0.0](docs/upgrading.md).\n\n**Docs:**\n\n* [Class Reference](docs/classes.md)\n* [Creating DBML schema](docs/creating_schema.md)\n* [Upgrading to PyDBML 1.0.0](docs/upgrading.md)\n* [Arbitrary Properties](docs/properties.md)\n\n\u003e PyDBML requires Python v3.8 or higher\n\n## Installation\n\nYou can install PyDBML using pip:\n\n```bash\npip3 install pydbml\n```\n\n## Quick start\n\nTo parse a DBML file, import the `PyDBML` class and initialize it with Path object\n\n```python\n\u003e\u003e\u003e from pydbml import PyDBML\n\u003e\u003e\u003e from pathlib import Path\n\u003e\u003e\u003e parsed = PyDBML(Path('test_schema.dbml'))\n\n```\n\nor with file stream\n\n```python\n\u003e\u003e\u003e with open('test_schema.dbml') as f:\n...     parsed = PyDBML(f)\n\n```\n\nor with entire source string\n\n```python\n\u003e\u003e\u003e with open('test_schema.dbml') as f:\n...     source = f.read()\n\u003e\u003e\u003e parsed = PyDBML(source)\n\u003e\u003e\u003e parsed\n\u003cDatabase\u003e\n\n```\n\nThe parser returns a Database object that is a container for the parsed DBML entities.\n\nYou can access tables inside the `tables` attribute:\n\n```python\n\u003e\u003e\u003e for table in parsed.tables:\n...     print(table.name)\n...\norders\norder_items\nproducts\nusers\nmerchants\ncountries\n\n```\n\nOr just by getting items by index or full table name:\n\n```python\n\u003e\u003e\u003e parsed[1]\n\u003cTable 'public' 'order_items'\u003e\n\u003e\u003e\u003e parsed['public.countries']\n\u003cTable 'public' 'countries'\u003e\n\n```\n\nOther attributes are:\n\n* **refs** — list of all references,\n* **enums** — list of all enums,\n* **table_groups** — list of all table groups,\n* **project** — the Project object, if was defined.\n\nGenerate SQL for your DBML Database by accessing the `sql` property:\n\n```python\n\u003e\u003e\u003e print(parsed.sql)  # doctest:+ELLIPSIS\nCREATE TYPE \"orders_status\" AS ENUM (\n  'created',\n  'running',\n  'done',\n  'failure',\n);\n\u003cBLANKLINE\u003e\nCREATE TYPE \"product status\" AS ENUM (\n  'Out of Stock',\n  'In Stock',\n);\n\u003cBLANKLINE\u003e\nCREATE TABLE \"orders\" (\n  \"id\" int PRIMARY KEY AUTOINCREMENT,\n  \"user_id\" int UNIQUE NOT NULL,\n  \"status\" \"orders_status\",\n  \"created_at\" varchar\n);\n...\n\n```\n\nGenerate DBML for your Database by accessing the `dbml` property:\n\n```python\n\u003e\u003e\u003e parsed.project.items['author'] = 'John Doe'\n\u003e\u003e\u003e print(parsed.dbml)  # doctest:+ELLIPSIS\nProject \"test_schema\" {\n    author: 'John Doe'\n    Note {\n        'This schema is used for PyDBML doctest'\n    }\n}\n\u003cBLANKLINE\u003e\nEnum \"orders_status\" {\n    \"created\"\n    \"running\"\n    \"done\"\n    \"failure\"\n}\n\u003cBLANKLINE\u003e\nEnum \"product status\" {\n    \"Out of Stock\"\n    \"In Stock\"\n}\n\u003cBLANKLINE\u003e\nTable \"orders\" [headercolor: #fff] {\n    \"id\" int [pk, increment]\n    \"user_id\" int [unique, not null]\n    \"status\" \"orders_status\"\n    \"created_at\" varchar\n}\n\u003cBLANKLINE\u003e\nTable \"order_items\" {\n    \"order_id\" int\n    \"product_id\" int\n    \"quantity\" int [default: 1]\n}\n...\n\n```\n","funding_links":[],"categories":["Python"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FVanderhoof%2FPyDBML","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FVanderhoof%2FPyDBML","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FVanderhoof%2FPyDBML/lists"}