Universal class that created to be a middleware, universal mapping for data from different parsers - simple-ddl-parser and py-models-parser
Project description
Table Meta
It’s a universal class that created to be a middleware, universal mapping for data from different parsers - simple-ddl-parser and py-models-parser.
Based on this middleware 2 libraries are worked - omymodels & fakeme.
It’s allow create 1 adapter for different inputs and produce output only on one standard - easy to maintain ad add different output variants.
All classes - Pydantic classes, so you can do with them anything that you can with Pydantic classes.
Library contains 2 different classes - TableMeta - main class to convert input relative to models or tables. Second - Type, for Enum types data.
How it use
Install
pip install table-meta
Usage
from table_meta import TableMeta
data = {your_table_definition}
table_data = TableMeta(**data)
Convert simple-ddl-parser input to TableMeta
Simple-ddl-parser: https://github.com/xnuinside/simple-ddl-parser
Pay attention that TableMeta expected data from simple-ddl-parser , that created with flag ‘group_by_type=True’ Example: result = DDLParser(ddl).run(group_by_type=True, output_mode=”bigquery”)
To convert simple-ddl-parser output to TableMeta - use method: ddl_to_meta()
Usage example:
from simple_ddl_parser import DDLParser
from table_meta import ddl_to_meta
ddl = "your ddl"
parser_result = DDLParser(ddl).run(group_by_type=True, output_mode="bigquery")
data = ddl_to_meta(parser_result)
# ddl_to_meta returns Dict with 2 keys {"tables": [], "types": []} inside lists you will have Table Meta a models
print(data)
Convert py-model-parser input to TableMeta
Py-models-parser: https://github.com/xnuinside/py-models-parser
Usage example:
from py_models_parser import parse
from table_meta import models_to_meta
model_from = "your python models, supported by parser"
result = parse(model_from)
data = models_to_meta(result)
# models_to_meta returns Dict with 2 keys {"tables": [], "types": []} inside lists you will have a Table Meta models
print(data)
Changelog
v0.1.1
Fix dependencies for python 3.6
v0.1.0
Table Meta moved from O!MyModels to separate library. To make it re-usebale in fakeme library.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for table_meta-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3b2edd065109610f757c074a60ccaa5d07e323d9ac56501fba1d00c5d68bb6b1 |
|
MD5 | 05bf5c41716519caf86e55b8c87cb5fe |
|
BLAKE2b-256 | d0c3a61f1c393d9fef598e0d57b0099206a895a04a9510575b6c86b24eba4b56 |