{"id":9213,"library":"pydbml","title":"PyDBML","description":"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.","status":"active","version":"1.2.1","language":"en","source_language":"en","source_url":"https://github.com/Vanderhoof/PyDBML","tags":["DBML","parser","builder","SQL","database","schema","modeling"],"install":[{"cmd":"pip install pydbml","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"note":"The `parse` function is a top-level import from the `pydbml` package.","wrong":"from pydbml.parser import parse","symbol":"parse","correct":"from pydbml import parse"}],"quickstart":{"code":"from pydbml import parse\n\n# Define a DBML string\ndbml_content = \"\"\"\nProject \"MyProject\" {\n    database_type: 'PostgreSQL'\n    Note: 'A simple example project'\n}\n\nTable \"users\" {\n    id int [pk, increment]\n    username varchar [unique, not null]\n    email varchar [unique]\n    created_at timestamp [default: `now()`]\n}\n\nTable \"posts\" {\n    id int [pk, increment]\n    title varchar [not null]\n    content text\n    user_id int [ref: > users.id]\n    created_at timestamp [default: `now()`]\n}\n\"\"\"\n\n# Parse the DBML content\ntry:\n    parsed_dbml = parse(dbml_content)\n    print(\"DBML parsed successfully.\")\n\n    # Render to SQL DDL\n    sql_output = parsed_dbml.sql()\n    print(\"\\n--- Generated SQL ---\")\n    print(sql_output)\n\n    # Optionally, render back to DBML (can differ slightly in formatting)\n    dbml_output = parsed_dbml.dbml()\n    print(\"\\n--- Generated DBML (re-rendered) ---\")\n    print(dbml_output)\n\nexcept Exception as e:\n    print(f\"An error occurred during parsing or rendering: {e}\")","lang":"python","description":"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."},"warnings":[{"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.","message":"Unicode 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.","severity":"breaking","affected_versions":">=1.2.0"},{"fix":"Upgrade to `pydbml 1.2.1` or newer to ensure correct SQL rendering of string and falsy default values in your generated DDL.","message":"SQL 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.","severity":"gotcha","affected_versions":"<1.2.1"},{"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.","message":"The 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.","severity":"gotcha","affected_versions":">=1.1.0"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Carefully review the DBML syntax around the indicated line `X` and column `Y`. Compare it against the official DBML specification (dbml.org) and ensure it adheres to pydbml's supported feature set. Common issues include missing commas, incorrect bracket usage, or malformed definitions.","cause":"The DBML input string contains a syntax error or uses a feature not yet supported by pydbml.","error":"pydbml.exceptions.PyDBMLParsingException: Error while parsing line X: Unexpected token 'Y'"},{"fix":"Modify your DBML file to use only ASCII characters for identifiers. Alternatively, if unicode identifiers are essential, consider using a `pydbml` version older than 1.2.0, acknowledging that it might not include the latest bug fixes or features.","cause":"You are attempting to parse a DBML file that uses unicode characters in identifiers (e.g., table or column names) on `pydbml` version 1.2.0 or newer, where this feature is temporarily disabled.","error":"pydbml.exceptions.PyDBMLParsingException: Error while parsing line X: Identifier '...' contains unsupported unicode characters"},{"fix":"Use `from pydbml import parse` to import the main parsing function. There is no `DBMLParser` class to instantiate directly.","cause":"You are trying to import a class named `DBMLParser` which does not exist in the `pydbml` library. The primary function for parsing is directly available as `parse`.","error":"ImportError: cannot import name 'DBMLParser' from 'pydbml'"}]}