Skip to main content

Library to generate DDL for different dialects

Project description

Simple DDL Generator

badge1 badge2 badge3 workflow

What is it?

Simple DDL Generator generate SQL DDL from 3 different inputs. Idea of the generator same as for parser to support as much as possible DDLs in future.

Simple DDL Generator generate SQL DDL from 3 input formats - 1st from output Simple DDL Parser (https://github.com/xnuinside/simple-ddl-parser), 2nd from py-models-parser - https://github.com/xnuinside/py-models-parser. Or you can directly pass TableMeta classes (https://github.com/xnuinside/table-meta) to generator

How to use

As usually - more samples in tests/

pip install simple-ddl-generator
from simple_ddl_generator import DDLGenerator
from simple_ddl_parser import DDLParser

# take initial DDL
ddl = """CREATE EXTERNAL TABLE IF NOT EXISTS database.table_name
    (
        day_long_nm     string,
        calendar_dt     date,
        source_batch_id string,
        field_qty       decimal(10, 0),
        field_bool      boolean,
        field_float     float,
        create_tmst     timestamp,
        field_double    double,
        field_long      bigint
    ) PARTITIONED BY (batch_id int);"""
# get result from parser
data = DDLParser(ddl).run(group_by_type=True, output_mode="bigquery")

# rename, for example, table name

data["tables"][0]["table_name"] = "new_table_name"
g = DDLGenerator(data)
g.generate()
print(g.result)

# and result will be:

"""
CREATE EXTERNAL TABLE "database.new_table_name" (
day_long_nm string,
calendar_dt date,
source_batch_id string,
field_qty decimal(10, 0),
field_bool boolean,
field_float float,
create_tmst timestamp,
field_double double,
field_long bigint)
PARTITIONED BY (batch_id int);
"""

Changelog

v0.1.0

Base Generator Functionality with several test cases.

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

simple-ddl-generator-0.1.0.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

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

simple_ddl_generator-0.1.0-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file simple-ddl-generator-0.1.0.tar.gz.

File metadata

  • Download URL: simple-ddl-generator-0.1.0.tar.gz
  • Upload date:
  • Size: 4.8 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 simple-ddl-generator-0.1.0.tar.gz
Algorithm Hash digest
SHA256 11eec9aa680935112ffc957f6d337c71b96fc9bc727e27165dab2eeb2c1c4b0b
MD5 dc2a68ff836b688d5ced95d5e21f1dbd
BLAKE2b-256 634a024b0dabe63e222c0d37efb4d52a55c48796f1a563f87568e62d23d9e27c

See more details on using hashes here.

File details

Details for the file simple_ddl_generator-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for simple_ddl_generator-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0da3b4d864acf099a0f97ef5c26fbc3856858a27c762e667ea99b95d94b48045
MD5 8e960dc22974b21349be105c7fb3875d
BLAKE2b-256 b42f2ff006a60c85078566e11547aa8dc4252dd5d560103b51800173b0aacc46

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