Skip to main content
Copyright (c) 2016 hanks

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Description: |Build Status| |Coverage Status|

pg diff
=======

A simple tool to diff serveral properties of schemas in two postgresql
databases.

Now supported diff options are:

- table\_name
- table\_count
- table\_schema
- row\_count
- table\_size
- index\_size
- ``table_total_size``
- sequence

Why
===

Recently I worked on database migration things, and very need a tool to
analyze the consistency between source and target database. So I make
this tool to some simple comparison, and it looks good to me:)

Prerequisite
============

You need to install ``postgresql`` firstly, because ``pg_diff`` will use
``psycopg2`` to execute some commands.

Installation
============

``pip install pg_diff``

Usage
=====

``pg_diff --type=table_count 'host=source dbname=test user=postgres password=secret port=5432' 'host=target dbname=test user=postgres password=secret port=5432' --verbose``

::

Usage:
pg_diff --type=T_NAME SOURCE_DSN TARGET_DSN [--verbose]
pg_diff -h | --help
pg_diff --version

Arguments:
SOURCE_DSN dsn for source database, like "host=xxx dbname=test user=postgres password=secret port=5432"
TARGET_DSN dsn for target database, like "host=xxx dbname=test user=postgres password=secret port=5432"

Options:
--type=T_NAME Type name to compare in category, valid input likes: table_name, table_count, table_schema, row_count, table size. index size, table_total_size, sequence
-h --help Show help info.
--verbose Show verbose information.
--version Show version.

Implementation
==============

Mainly using libraries below to make this tool:

- docopt==0.6.2
- schema==0.6.5
- deepdiff==2.5.1
- psycopg2==2.6.2

And I use some SQL to query the status of schema, like table size, index
size and etc.

Contribution
============

#. Fork the repository on GitHub.
#. Make a branch off of master and commit your changes to it.
#. Run the tests with ``tox``

- Either use ``tox`` to build against all supported Python versions (if
you have them installed) or use ``tox -e py{version}`` to test
against a specific version, e.g., ``tox -e py27`` or ``tox -e py33``.

#. Submit a Pull Request to the master branch on GitHub.

If you’d like to have a development environment for ``pg_diff``, you
should create a virtualenv and then do ``pip install -e .`` from within
the directory.

Lisence
=======

MIT Lisence

.. |Build Status| image:: https://travis-ci.org/hanks/pg_diff.svg?branch=master
:target: https://travis-ci.org/hanks/pg_diff
.. |Coverage Status| image:: https://coveralls.io/repos/github/hanks/pg_diff/badge.svg?branch=master
:target: https://coveralls.io/github/hanks/pg_diff?branch=master
Keywords: pg_diff postgresql diff
Platform: UNKNOWN
Classifier: Topic :: Utilities
Classifier: Development Status :: 5 - Production/Stable
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.6
Classifier: Programming Language :: Python :: 2.7
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent

Metadata

Release files for pg-diff 0.2.1

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

Source distribution (sdist)

Source distribution for pg-diff 0.2.1
File Size Uploaded Provenance Actions
pg_diff-0.2.1.tar.gz 7.7 kB Without provenance Details for pg_diff-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pg-diff 0.2.1
File Interpreter ABI Platform Actions
pg_diff-0.2.1-py2.py3-none-any.whl Python 3, Python 2 none any Details for pg_diff-0.2.1-py2.py3-none-any.whl

Total release size: 17.8 kB

Release files / pg_diff-0.2.1.tar.gz

Download URL pg_diff-0.2.1.tar.gz
Size 7.7 kB
Tags Source
SHA-256 checksum
How to use checksums
4c7e1f286bd02cd44df614a5704debcf21f6c8dee75c11b468287146f9d9a76a
BLAKE2b-256 checksum
How to use checksums
7944fb672143fa4fd0311265bdb480a8e77eae1c19abddc2cf3903566771259b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / pg_diff-0.2.1-py2.py3-none-any.whl

Download URL pg_diff-0.2.1-py2.py3-none-any.whl
Size 10.2 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
cad5e9a95b2c9e4cdf7e8804f284f26ff7d14e6ac617c03399454be8f05ca79c
BLAKE2b-256 checksum
How to use checksums
9ec70a039608aee980bcef3eb05dd7fd94bcd6293ba004d10c037bd0a8eecf45
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for pg-diff 0.2.1

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.

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