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
- Python
>= 3.12 - sqlalchemy
>= 2.0 - pydantic
>= 2.0
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file comdab-0.3.1.tar.gz.
File metadata
- Download URL: comdab-0.3.1.tar.gz
- Upload date:
- Size: 70.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
939ba527f823ecb3356a9de7d9e0fb81e7e59744271b9e2552c13bddf437e512
|
|
| MD5 |
66bf96ef7c54b7748e8ec217e2d31280
|
|
| BLAKE2b-256 |
54fa1735aa9ef38b8d169641156685570b16a29f671caff21c3a7d4c805a04c9
|
Provenance
The following attestation bundles were made for comdab-0.3.1.tar.gz:
Publisher:
release.yml on loic-simon/comdab
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
comdab-0.3.1.tar.gz -
Subject digest:
939ba527f823ecb3356a9de7d9e0fb81e7e59744271b9e2552c13bddf437e512 - Sigstore transparency entry: 1247415036
- Sigstore integration time:
-
Permalink:
loic-simon/comdab@6bce2e6228c9e4b8a446f968d53b919526a143ba -
Branch / Tag:
refs/tags/v0.3.1 - Owner: https://github.com/loic-simon
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@6bce2e6228c9e4b8a446f968d53b919526a143ba -
Trigger Event:
release
-
Statement type:
File details
Details for the file comdab-0.3.1-py3-none-any.whl.
File metadata
- Download URL: comdab-0.3.1-py3-none-any.whl
- Upload date:
- Size: 27.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
72b00dbba6b19d73164f570f35c474346ed25880efad62b35f53837534857529
|
|
| MD5 |
34dab84ca828cfd54270f446189d608d
|
|
| BLAKE2b-256 |
90a0ac121cc4b7babd8ab65c9af80c27de2d64467470fd373ba06b0ee01a9f5c
|
Provenance
The following attestation bundles were made for comdab-0.3.1-py3-none-any.whl:
Publisher:
release.yml on loic-simon/comdab
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
comdab-0.3.1-py3-none-any.whl -
Subject digest:
72b00dbba6b19d73164f570f35c474346ed25880efad62b35f53837534857529 - Sigstore transparency entry: 1247415084
- Sigstore integration time:
-
Permalink:
loic-simon/comdab@6bce2e6228c9e4b8a446f968d53b919526a143ba -
Branch / Tag:
refs/tags/v0.3.1 - Owner: https://github.com/loic-simon
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@6bce2e6228c9e4b8a446f968d53b919526a143ba -
Trigger Event:
release
-
Statement type: