Skip to main content

Splits a DDL file generated by pgModeler by database objects into single DDL files.

Project description

ddlsplit

Splits a DDL file generated by pgModeler into single files by database objects (schema, extension, table etc.). Comments on Tables are parsed as multiline top-level comments, which can be utilized by sphinx-sql (fork of jackscodemonkey's sphinx-sql).

Installation

pip install ddlsplit

Usage

Run as a program

ddlsplit <ddl.sql> <output-dir>

Or clone this repo and run the program with poetry from the cloned repository without installation:

poetry install
poetry run ddlsplit <ddl.sql> <output-dir>

Use as a module

Make sure, ddlsplit is in your $PATH or project's namespace!

import ddlsplit


ddl_code = '''
...
'''

Reverse Engineering A Database & Its Documentation

pgModeler → ddlsplit → sphinx w/ sphinx-sql

If you maintain your database model with a graphical data modeling tool like pgModeler, you can build a pipeline to automatically build your documentation with sphinx-sql, e.g. by calling pgModeler and ddlsplit from your sphinx' Makefile.

This approach lets you keep the documentation of your SQL code inside the code itself, thus reducing overhead costs by keeping code and documentation residing in multiple places in sync.

# Optional: Reverse engineering an existing database:
pgmodeler-cli \
        -platform offscreen \
        --export-to-file \
        --import-db \
        --ignore-errors \
        --conn-alias local-db \
        --input-db demodb \
        --output demo.sql \
        --pgsql-ver 12.0

# Export pgModeler's dbm to sql file:
pgmodeler-cli \
        -platform offscreen \
        --export-to-file \
        --input demo.dbm \
        --output demo.sql \
        --pgsql-ver 12.0

Example for top level comment for a table with pgModeler:

Purpose:
This a new table to show how auto documentation can add new objects quickly.
Dependent Objects:
	Type	|	Name
	Schema	|	my_test_schema
ChangeLog:
	Date	|	Author	|	Ticket	|	Modification
	2020-12-26	|	Developer_2	|	T-247	|	Initial Definition

Results in:

COMMENT ON TABLE public.find IS E'Purpose:\nThis a new table to show how auto documentation can add new objects quickly.\nDependent Objects:\n\tType\t|\tName\n\tSchema\t|\tmy_test_schema\nChangeLog:\n\tDate\t|\tAuthor\t|\tTicket\t|\tModification\n\t2020-12-26\t|\tDeveloper_2\t|\tT-247\t|\tInitial Definition';

Developing

poetry install
poetry build

Contributing

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

ddlsplit-0.1.2.tar.gz (15.7 kB view details)

Uploaded Source

Built Distribution

ddlsplit-0.1.2-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

File details

Details for the file ddlsplit-0.1.2.tar.gz.

File metadata

  • Download URL: ddlsplit-0.1.2.tar.gz
  • Upload date:
  • Size: 15.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.4 CPython/3.7.3 Linux/4.9.0-8-amd64

File hashes

Hashes for ddlsplit-0.1.2.tar.gz
Algorithm Hash digest
SHA256 152ebb9faa831eb92bf385909b53145cfb8d903918e14b7fa922a2ea8df90e75
MD5 1995c2efd932b13a2a11d8917cecd23f
BLAKE2b-256 c2765628619148492ffa5b3f9799e146d1ec71bc6c2019a1017107ce9533cbb8

See more details on using hashes here.

File details

Details for the file ddlsplit-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: ddlsplit-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 15.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.4 CPython/3.7.3 Linux/4.9.0-8-amd64

File hashes

Hashes for ddlsplit-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ca1aae5a9f7634669f8674127694f77f1ac10e31b3dcc8cf681442b82664d250
MD5 6daae62c74bcf72b727dcda4e786ca4e
BLAKE2b-256 36b3485a667dd2fac21c567f2d7ab7909b4be755f89a09167d10d44306bd77c3

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