Skip to main content

Compare Database Schemas

Project description

comdab — Compare Database Schemas

comdab allows you to compare in depth two database schemas to find all differences: missing columns, different nullabilities or defaults, slight changes in function or triggers definitions...

[!WARNING]

comdab is still in development, only tested with PostgreSQL 14 to date.

All feedback and contributions are welcome!

Installation

Use pip to install comdab:

pip install comdab

Requirements

Goals

comdab is especially useful in combination with a migration tool like Alembic, to make sure that applying a migration to an existing database and creating a new database from scratch produce the exact same schema.

Indeed, while migration tools can auto-detect model changes and write automatically the migrations to apply to pre-existing databases, it does not cover the whole schema complexity, and does not prevent human errors (like modifying the model without re-generating migrations, or manually editing migrations in a slightly wrong way...)

This may cause dangerous and hard to spot bugs, especially if your unit tests and CI run on a fresh database created from the Python-written model, and not on pre-existing databases with the new migration applied.

By running comdab, you can ensure the two are the nearly-exact same.

comdab stands on the shoulders of the SQLAlchemy library, used to connect to the database and for most of schema introspection.

Usage

from comdab import compare_databases
from sqlalchemy import create_engine

engine_1 = create_engine("postgresql://user:pass@host/foo")
engine_2 = create_engine("postgresql://user:pass@host/bar")

with engine_1.connect() as left_conn, engine_2.connect() as right_conn:
    reports = compare_databases(left_conn, right_conn)

if reports:
    print("❌ Database schemas are different:", reports)
else:
    print("✅ Database schemas are the same!")

See documentation for configuration and other details.

Contributing

Issues and pull requests are welcome!

License

This work is shared under the MIT license;

@ 2025 Loïc Simon (loic.simon@espci.org)

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

comdab-0.1.0.tar.gz (54.2 kB view details)

Uploaded Source

Built Distribution

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

comdab-0.1.0-py3-none-any.whl (26.0 kB view details)

Uploaded Python 3

File details

Details for the file comdab-0.1.0.tar.gz.

File metadata

  • Download URL: comdab-0.1.0.tar.gz
  • Upload date:
  • Size: 54.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for comdab-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0197c3f42a99ea5bcc4f1d40c4ad519e6843673767dfe83dceba3de92e92eca8
MD5 3e0788f9267aa0d937a48e1e6323aaa8
BLAKE2b-256 cdde0bfd94099a41599477c78fade218b7a6b4b7181c740b4af98db6fbf75f55

See more details on using hashes here.

Provenance

The following attestation bundles were made for comdab-0.1.0.tar.gz:

Publisher: release.yml on loic-simon/comdab

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: comdab-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 26.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for comdab-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f4a8bf780b10e485c97e9e06f8a8b00ec3c2309352a3670168ccf6b9eae05d6c
MD5 1792c046cae17799329c1a6f5253eac8
BLAKE2b-256 f47f8ead831ec31cff0800d982c66bdde131838a5fa9e99c674583b7c28c90d2

See more details on using hashes here.

Provenance

The following attestation bundles were made for comdab-0.1.0-py3-none-any.whl:

Publisher: release.yml on loic-simon/comdab

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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