Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/quantco/sqlcompyre
Python package for comparing SQL tables and databases.
https://github.com/quantco/sqlcompyre
python sql
Last synced: about 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 (5 months ago)
- Default Branch: main
- Last Pushed: 2024-11-01T11:56:45.000Z (2 months ago)
- Last Synced: 2024-11-01T12:29:17.772Z (2 months ago)
- Topics: python, sql
- Language: Python
- Homepage:
- Size: 213 KB
- Stars: 1
- Watchers: 4
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# SQLCompyre
[![CI](https://img.shields.io/github/actions/workflow/status/quantco/sqlcompyre/ci.yml?style=flat-square&branch=main)](https://github.com/quantco/sqlcompyre/actions/workflows/ci.yml)
[![conda-forge](https://img.shields.io/conda/vn/conda-forge/sqlcompyre?logoColor=white&logo=conda-forge&style=flat-square)](https://prefix.dev/channels/conda-forge/packages/sqlcompyre)
[![Documentation](https://img.shields.io/badge/docs-latest-success?branch=main&style=flat-square)](https://sqlcompyre.readthedocs.io/en/latest/)
[![pypi-version](https://img.shields.io/pypi/v/sqlcompyre.svg?logo=pypi&logoColor=white&style=flat-square)](https://pypi.org/project/sqlcompyre)
[![python-version](https://img.shields.io/pypi/pyversions/sqlcompyre?logoColor=white&logo=python&style=flat-square)](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
```