-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added support for ddl generation from py-models-parser output
- Loading branch information
Showing
11 changed files
with
322 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,11 @@ | ||
**v0.2.0** | ||
|
||
1. Updated parser version in tests. | ||
2. Added support for EXTERNAL & IF NOT EXISTS statetements. | ||
3. Added support for using py-models-parser output as input and added sample in README.md: | ||
|
||
DDL Generation from Pydantic, SQLAlchemy and other python models. | ||
|
||
**v0.1.0** | ||
|
||
Base Generator Functionality with several test cases. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from typing import Dict | ||
from simple_ddl_generator.type_converter import prepare_type | ||
|
||
|
||
def default_cleaner(default_value: str): | ||
if default_value: | ||
if 'datetime.' in default_value: | ||
default_value = default_value.split('datetime.')[-1] | ||
return default_value | ||
|
||
|
||
def prepare_models_data(data: Dict): | ||
for table in data["tables"]: | ||
for column in table.columns: | ||
column.type = prepare_type(column.type) | ||
column.default = default_cleaner(column.default) | ||
return data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{% include "column_base.jinja2" %}{{" NOT NULL" if not column.nullable else ""}}{{" PRIMARY KEY" if column.primary_key else ""}}{{" UNIQUE" if column.unique else ""}}{{ columnn.references if column.references}}{{ columnn.default if column.default}} | ||
{% include "column_base.jinja2" %}{{" NOT NULL" if not column.nullable else ""}}{{" PRIMARY KEY" if column.primary_key else ""}}{{" UNIQUE" if column.unique else ""}}{{ column.references if column.references}}{{ " DEFAULT " + column.default if column.default}} |
Oops, something went wrong.