https://github.com/quantco/sqlcompyre
Python package for comparing SQL tables and databases.
https://github.com/quantco/sqlcompyre
python sql
Last synced: 2 months ago
JSON representation
Python package for comparing SQL tables and databases.
- Host: GitHub
- URL: https://github.com/quantco/sqlcompyre
- Owner: Quantco
- License: bsd-3-clause
- Created: 2024-07-25T16:27:55.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2025-04-07T13:12:24.000Z (3 months ago)
- Last Synced: 2025-04-24T17:08:52.859Z (3 months ago)
- Topics: python, sql
- Language: Python
- Homepage: https://sqlcompyre.readthedocs.io/en/latest/
- Size: 324 KB
- Stars: 3
- Watchers: 7
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# SQLCompyre
[](https://github.com/quantco/sqlcompyre/actions/workflows/ci.yml)
[](https://prefix.dev/channels/conda-forge/packages/sqlcompyre)
[](https://sqlcompyre.readthedocs.io/en/latest/)
[](https://pypi.org/project/sqlcompyre)
[](https://pypi.org/project/sqlcompyre)SQLCompyre is a simple Python package that allows you to find and explore the differences between SQL tables, schemas, and entire databases. It provides both a Python interface and a CLI, allowing it to be used for both ad-hoc comparisons as well as in-depth analyses.
SQLCompyre is designed to be dialect-agnostic and should, thus, work with most database systems out-of-the-box.
## Usage example
Given a connection to a database, this snippet will print a report of the differences between two tables:
```python
import sqlalchemy as sa
import sqlcompyre as scengine = sa.create_engine("")
comparison = sc.compare_tables(engine, "", "")report = comparison.summary_report()
print(report)
```To find more examples and get started, please visit the [documentation](https://sqlcompyre.readthedocs.io/en/latest/).
## Installation
SQLCompyre can be installed via `pip` or `conda`:
```bash
pip install sqlcompyre
# or
micromamba install sqlcompyre
# or
conda install sqlcompyre
```Details on its usage can be found in the [documentation](https://sqlcompyre.readthedocs.io/en/latest/).
## Development
This project is managed by [pixi](https://pixi.sh).
You can install the package in development mode using:```bash
git clone https://github.com/quantco/sqlcompyre
cd sqlcompyrepixi run pre-commit-install
pixi run postinstall
```### Running Tests Locally
1. Make sure you have `msodbcsql18` installed, or install it [here](https://learn.microsoft.com/en-us/sql/connect/odbc/download-odbc-driver-for-sql-server)
2. Make sure you have `Docker` installed, or install it [here](https://docs.docker.com/get-docker/)
3. Create a local test database with the following command:
```bash
docker compose up
```4. Set environment variable
```bash
export DB_CONNECTION_STRING="mssql+pyodbc://sa:Passw0rd@localhost:1435/master?driver=ODBC+Driver+18+for+SQL+Server&Encrypt=no"
```5. Navigate to the main directory of this repository and run pytest.
```bash
pixi run test
```