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 Tests Pipeline

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.

Python 3.9+.

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

See CHANGELOG.md.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

table_meta-1.0.0-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: table_meta-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.12

File hashes

Hashes for table_meta-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 37fb8b8722cf33a73e35f12dbaa88e2a02dc0151c65b91fdb229d5b34aba5399
MD5 2b361a00bbb5038b132f6fe1b3220b8d
BLAKE2b-256 a4faef838c097e8f833220636b196565f3fc9b5b589684134f3502f641fffaa8

See more details on using hashes here.

Supported by

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