Skip to main content

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

badge1 badge2 badge3 workflow

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.2.1

  1. Added support for parsing ‘dataset’ from data as ‘table_schema’ also added fields like ‘project’ (to support BigQuery metadata)

  2. Depencencies updated

  3. Added HQL Table Properties

v0.1.5

  1. field ‘attrs’ added to Type to store values from py-models-parser output

v0.1.3

  1. ‘parents’ added to Type and to Table

v0.1.1

  1. Fix dependencies for python 3.6

v0.1.0

  1. Table Meta moved from O!MyModels to separate library. To make it re-usebale in fakeme library.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

table-meta-0.3.2.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

table_meta-0.3.2-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file table-meta-0.3.2.tar.gz.

File metadata

  • Download URL: table-meta-0.3.2.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.10 CPython/3.8.12 Darwin/19.6.0

File hashes

Hashes for table-meta-0.3.2.tar.gz
Algorithm Hash digest
SHA256 0854d6d3af847a84ca7402a83155e7d76d823cdb94500368c6ccdc046bd1b551
MD5 38b9638f55a9d42efdd59003dca8a5eb
BLAKE2b-256 1f1576559c6a76a664c77e211c69c36743d2aef6d356231a05049889cb9d9d60

See more details on using hashes here.

File details

Details for the file table_meta-0.3.2-py3-none-any.whl.

File metadata

  • Download URL: table_meta-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.10 CPython/3.8.12 Darwin/19.6.0

File hashes

Hashes for table_meta-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c858c692b93aeb6223425a74ea471734c3cd87472b96fa2e743dcfd6b8cfca5a
MD5 06a51cbfc8f7d4bde554c0dd4fe58ebd
BLAKE2b-256 10abc2f12921a06cf47cf300c19258c9dc4042d706f5f9d58444813063effdd5

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page