Skip to content

Commit

Permalink
Document usage
Browse files Browse the repository at this point in the history
  • Loading branch information
fivegrant committed Oct 17, 2022
1 parent 252b7dd commit 43a8593
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 7 deletions.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,24 @@
# dbml-builder
Generates Pydantic and SQLAlchemy from a DBML file.

## Usage

Install using pip:

```
pip install dbml_builder
```

Generate your ORM and schemas by running:

```
model-build generate ./project.dbml src/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 src/generated
```
or call `verify` directly in Python code.

2 changes: 1 addition & 1 deletion dbml_builder/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from build import get_dbml_version, verify, generate_validation
from dbml_builder.build import get_dbml_version, verify, generate_models
4 changes: 2 additions & 2 deletions dbml_builder/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from os.path import exists, join
from pathlib import Path

from fix import patch
from dbml_builder.fix import patch

INFO = 'info.json'
SCHEMAS = 'schema.py'
Expand Down Expand Up @@ -54,7 +54,7 @@ def verify(version: str, generated_dir: str) -> bool:
return False


def generate_validation(dbml_path: str, generated_dir: str) -> None:
def generate_models(dbml_path: str, generated_dir: str) -> None:
"""
Generate model code from DBML
Expand Down
4 changes: 2 additions & 2 deletions dbml_builder/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from click import argument, echo, group

from build import generate_validation, verify
from dbml_builder.build import generate_models, verify

@group()
def main() -> None:
Expand Down Expand Up @@ -36,7 +36,7 @@ def generate(path_to_dbml: str, path_to_generated_dir: str) -> None:
`gen` should only be called when developing using a new version of the DBML.
"""
generate_validation(path_to_dbml, path_to_generated_dir)
generate_models(path_to_dbml, path_to_generated_dir)
echo('Generated pydantic schemas')


Expand Down
5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
[tool.poetry]
name = "dbml-builder"
version = "0.1.0"
version = "0.1.4"
description = ""
authors = ["Five Grant <[email protected]>"]
readme = "README.md"
packages = [{include = "dbml_builder"}]
repository = "https://github.com/jataware/dbml-builder"
license = "MIT"
keywords = ["dbml", "sql"]

[tool.poetry.urls]
"Bug Tracker" = "https://github.com/jataware/dbml-builder/issues"
Expand Down

0 comments on commit 43a8593

Please sign in to comment.