Skip to main content

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

Metadata

Release files for ddlsplit 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ddlsplit 0.1.2
File Size Uploaded Provenance Actions
ddlsplit-0.1.2.tar.gz 15.7 kB Without provenance Details for ddlsplit-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ddlsplit 0.1.2
File Interpreter ABI Platform Actions
ddlsplit-0.1.2-py3-none-any.whl Python 3 none any Details for ddlsplit-0.1.2-py3-none-any.whl

Total release size: 31.6 kB

Release files / ddlsplit-0.1.2.tar.gz

Download URL ddlsplit-0.1.2.tar.gz
Size 15.7 kB
Tags Source
SHA-256 checksum
How to use checksums
152ebb9faa831eb92bf385909b53145cfb8d903918e14b7fa922a2ea8df90e75
BLAKE2b-256 checksum
How to use checksums
c2765628619148492ffa5b3f9799e146d1ec71bc6c2019a1017107ce9533cbb8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.4 CPython/3.7.3 Linux/4.9.0-8-amd64

Release files / ddlsplit-0.1.2-py3-none-any.whl

Download URL ddlsplit-0.1.2-py3-none-any.whl
Size 15.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ca1aae5a9f7634669f8674127694f77f1ac10e31b3dcc8cf681442b82664d250
BLAKE2b-256 checksum
How to use checksums
36b3485a667dd2fac21c567f2d7ab7909b4be755f89a09167d10d44306bd77c3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.4 CPython/3.7.3 Linux/4.9.0-8-amd64

Security for ddlsplit 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page