dbml-builder


Namedbml-builder JSON
Version 0.4.1 PyPI version JSON
download
home_page
SummaryBuilds usable models from DBML
upload_time2023-03-13 19:16:48
maintainer
docs_urlNone
authorFive Grant
requires_python>=3.10,<4.0
licenseMIT
keywords dbml sql
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # dbml-builder

Generates Pydantic and SQLAlchemy from a DBML file.

This package is for users wanting to use their data model represented
in [DBML](https://www.dbml.org/home/) in production. `dbml-builder` accomplishes this
by:
1. Generating Pydantic and SQLAlchemy code.
2. Verifying existing generated code to see if it matches the specified version and
   has not been changed since creation.

Currently, there doesn't seem to be a good solution for code generation with DBML in Python
hence the creation of `dbml-builder`. Additionally, large software systems tend to break as
Pydantic schemas are modified which is the reason why the package includes verification
functionality.

`dbml-builder` is new and actively developed. If you have any feature requests or issues,
please submit them [here](https://github.com/jataware/dbml-builder/issues). 


## Installation

Install using pip:

```
pip install dbml_builder
```

## Usage

Generate your ORM and schemas by running:

```
model-build generate ./project.dbml ./generated
```
or call `generate_models` directly in Python code.


You can check to if the model code is still valid by running:
```
model-build check v0.9.3 ./generated
```
or call `verify` directly in Python code.

Note that the version is what is specified in the `note` for
a given project in DBML.

### Example

Suppose we have a project:

```
>> ls
src/  LICENSE  poetry.lock  data-model.dbml  pyproject.toml
```
where `src` contains your code for your python project.

We can automatically generate code using:

```
pip install dbml_builder
model-build generate ./data-model.dbml ./src/generated
```

We can now submit `src/generated` to version control and
use the generated code in a module:
```
from generated.schema import SOME_PYDANTIC_SCHEMA
from generated.orm import SOME_SQLALCHEMY_TABLE
```

We can also ensure the generated code is not changed by 
placing a check in our code:
```
# src/main.py
from dbml_builder import verify

verify('v0.1.0', '../data-model.dbml')
```

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "dbml-builder",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10,<4.0",
    "maintainer_email": "",
    "keywords": "dbml,sql",
    "author": "Five Grant",
    "author_email": "five@jataware.com",
    "download_url": "https://files.pythonhosted.org/packages/06/79/67d66ab2f108d7db035f6bfcc600b9d45fd504770d93a94a237189e69b4f/dbml_builder-0.4.1.tar.gz",
    "platform": null,
    "description": "# dbml-builder\n\nGenerates Pydantic and SQLAlchemy from a DBML file.\n\nThis package is for users wanting to use their data model represented\nin [DBML](https://www.dbml.org/home/) in production. `dbml-builder` accomplishes this\nby:\n1. Generating Pydantic and SQLAlchemy code.\n2. Verifying existing generated code to see if it matches the specified version and\n   has not been changed since creation.\n\nCurrently, there doesn't seem to be a good solution for code generation with DBML in Python\nhence the creation of `dbml-builder`. Additionally, large software systems tend to break as\nPydantic schemas are modified which is the reason why the package includes verification\nfunctionality.\n\n`dbml-builder` is new and actively developed. If you have any feature requests or issues,\nplease submit them [here](https://github.com/jataware/dbml-builder/issues). \n\n\n## Installation\n\nInstall using pip:\n\n```\npip install dbml_builder\n```\n\n## Usage\n\nGenerate your ORM and schemas by running:\n\n```\nmodel-build generate ./project.dbml ./generated\n```\nor call `generate_models` directly in Python code.\n\n\nYou can check to if the model code is still valid by running:\n```\nmodel-build check v0.9.3 ./generated\n```\nor call `verify` directly in Python code.\n\nNote that the version is what is specified in the `note` for\na given project in DBML.\n\n### Example\n\nSuppose we have a project:\n\n```\n>> ls\nsrc/  LICENSE  poetry.lock  data-model.dbml  pyproject.toml\n```\nwhere `src` contains your code for your python project.\n\nWe can automatically generate code using:\n\n```\npip install dbml_builder\nmodel-build generate ./data-model.dbml ./src/generated\n```\n\nWe can now submit `src/generated` to version control and\nuse the generated code in a module:\n```\nfrom generated.schema import SOME_PYDANTIC_SCHEMA\nfrom generated.orm import SOME_SQLALCHEMY_TABLE\n```\n\nWe can also ensure the generated code is not changed by \nplacing a check in our code:\n```\n# src/main.py\nfrom dbml_builder import verify\n\nverify('v0.1.0', '../data-model.dbml')\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Builds usable models from DBML",
    "version": "0.4.1",
    "split_keywords": [
        "dbml",
        "sql"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b04c083374df35b5a812430bdbe4dceaf7fdc0474319e3a37403857715f373ce",
                "md5": "2dd64a242cc86da909b923025cc630cc",
                "sha256": "f9c9f5a950f9378fe98e9df3ed73661a8d8759dd0d3628b16bf6f9547e8287fe"
            },
            "downloads": -1,
            "filename": "dbml_builder-0.4.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "2dd64a242cc86da909b923025cc630cc",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10,<4.0",
            "size": 6679,
            "upload_time": "2023-03-13T19:16:46",
            "upload_time_iso_8601": "2023-03-13T19:16:46.870031Z",
            "url": "https://files.pythonhosted.org/packages/b0/4c/083374df35b5a812430bdbe4dceaf7fdc0474319e3a37403857715f373ce/dbml_builder-0.4.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "067967d66ab2f108d7db035f6bfcc600b9d45fd504770d93a94a237189e69b4f",
                "md5": "2e26e01589d786c300398300bee050eb",
                "sha256": "5ddbfa8f0906c689c40c0f142c19c23549c1dc4daba725d097222dcbe5b42bdf"
            },
            "downloads": -1,
            "filename": "dbml_builder-0.4.1.tar.gz",
            "has_sig": false,
            "md5_digest": "2e26e01589d786c300398300bee050eb",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10,<4.0",
            "size": 5823,
            "upload_time": "2023-03-13T19:16:48",
            "upload_time_iso_8601": "2023-03-13T19:16:48.406059Z",
            "url": "https://files.pythonhosted.org/packages/06/79/67d66ab2f108d7db035f6bfcc600b9d45fd504770d93a94a237189e69b4f/dbml_builder-0.4.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-03-13 19:16:48",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "dbml-builder"
}
        
Elapsed time: 0.04400s