{ "info": { "author": "Petras Zdanavicius", "author_email": "petraszd@gmail.com", "bugtrack_url": null, "classifiers": [ "Environment :: Console", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Topic :: Utilities" ], "description": "Postgres DB diff\n================\n\nCommand line tool to compare two PostgreSQL databases. It is based on parsing\n``psql`` meta commands output. Such as ``\\dt`` for tables and ``\\dv`` for\nviews.\n\nhttps://www.postgresql.org/docs/current/static/app-psql.html\n\n\nHow to install\n==============\n\nThere are two options:\n\n1) Use any python package installing tool. Recommended ``pip``.\n2) Just copy/paste ``postgresdbdiff.py`` into your dir and run it using ``python postgresdbdiff.py``\n\n\nUsage\n=====\n\n::\n\n usage: postgresdbdiff.py [-h] --db1 DB1 --db2 DB2 [--diff-folder DIFF_FOLDER]\n\n optional arguments:\n -h, --help show this help message and exit\n --db1 DB1 First DB name\n --db2 DB2 Second DB name\n --diff-folder DIFF_FOLDER\n Directory to output diffs\n\n\n\nExample\n=======\n\nCreate two DBs. One using this SQL:\n\n.. code-block:: sql\n\n CREATE TABLE table_a (\n id INTEGER PRIMARY KEY,\n test_unique VARCHAR (100) UNIQUE,\n test_not_null VARCHAR (100) NOT NULL,\n test_checks INTEGER NOT NULL\n );\n\n CREATE TABLE table_b (\n id INTEGER PRIMARY KEY,\n table_a_id integer REFERENCES table_a (id)\n );\n\n CREATE TABLE table_c (\n id INTEGER PRIMARY KEY\n );\n\n CREATE VIEW view_a AS SELECT\n id, test_unique, 42 AS some_number\n FROM table_a;\n\nOther using this SQL:\n\n.. code-block:: sql\n\n CREATE TABLE table_a (\n id INTEGER PRIMARY KEY,\n test_unique VARCHAR (100),\n test_not_null VARCHAR (100),\n test_checks INTEGER NOT NULL CHECK (test_checks > 0)\n );\n\n CREATE TABLE table_b (\n id INTEGER PRIMARY KEY,\n table_a_no integer REFERENCES table_a (id)\n );\n\n CREATE VIEW view_a AS SELECT\n id, test_unique\n FROM table_a;\n\nThen run this command ::\n\n python postgresdbdiff.py --db1 diff_a --db2 diff_b --diff-folder diffs\n\nOutput should be like this ::\n\n TABLES: additional in \"diff_a\"\n table_c\n\n TABLES: not matching\n table_a\n table_b\n\n VIEWS: not matching\n view_a\n\nAnd there should be the folder named ``diffs`` with files looking like this\n\n.. code-block:: diff\n\n # diffs/table_a.diff\n --- TABLES.diff_a.table_a\n +++ TABLES.diff_b.table_a\n @@ -1,12 +1,13 @@\n Table \"public.table_a\"\n Column | Type | Collation | Nullable | Default\n ---------------+------------------------+-----------+----------+---------\n id | integer | | not null |\n test_checks | integer | | not null |\n - test_not_null | character varying(100) | | not null |\n + test_not_null | character varying(100) | | |\n test_unique | character varying(100) | | |\n Indexes:\n \"table_a_pkey\" PRIMARY KEY, btree (id)\n - \"table_a_test_unique_key\" UNIQUE CONSTRAINT, btree (test_unique)\n +Check constraints:\n + \"table_a_test_checks_check\" CHECK (test_checks > 0)\n Referenced by:\n - TABLE \"table_b\" CONSTRAINT \"table_b_table_a_id_fkey\" FOREIGN KEY (table_a_id) REFERENCES table_a(id)\n + TABLE \"table_b\" CONSTRAINT \"table_b_table_a_no_fkey\" FOREIGN KEY (table_a_no) REFERENCES table_a(id)\n\n\n # diffs/table_b.diff\n --- TABLES.diff_a.table_b\n +++ TABLES.diff_b.table_b\n @@ -1,9 +1,9 @@\n Table \"public.table_b\"\n Column | Type | Collation | Nullable | Default\n ------------+---------+-----------+----------+---------\n id | integer | | not null |\n - table_a_id | integer | | |\n + table_a_no | integer | | |\n Indexes:\n \"table_b_pkey\" PRIMARY KEY, btree (id)\n Foreign-key constraints:\n - \"table_b_table_a_id_fkey\" FOREIGN KEY (table_a_id) REFERENCES table_a(id)\n + \"table_b_table_a_no_fkey\" FOREIGN KEY (table_a_no) REFERENCES table_a(id)\n\n\n # diffs/view_a.diff\n --- VIEWS.diff_a.view_a\n +++ VIEWS.diff_b.view_a\n @@ -1,6 +1,5 @@\n View \"public.view_a\"\n Column | Type | Collation | Nullable | Default\n -------------+------------------------+-----------+----------+---------\n id | integer | | |\n - some_number | integer | | |\n test_unique | character varying(100) | | |\n\n\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/petraszd/postgres-db-diff", "keywords": "postgresql database comparison command line utility", "license": "", "maintainer": "", "maintainer_email": "", "name": "postgres-db-diff", "package_url": "https://pypi.org/project/postgres-db-diff/", "platform": "", "project_url": "https://pypi.org/project/postgres-db-diff/", "project_urls": { "Homepage": "https://github.com/petraszd/postgres-db-diff" }, "release_url": "https://pypi.org/project/postgres-db-diff/0.9.1/", "requires_dist": null, "requires_python": "", "summary": "Command line tool to compare two PostgreSQL databases", "version": "0.9.1" }, "last_serial": 3445612, "releases": { "0.9.1": [ { "comment_text": "", "digests": { "md5": "d5c49768063ae5e4bd609bc05ff68c49", "sha256": "0ac4f248e2059e2d25add34a754e787ab06fb687b79c2b6c12b8fe44f3ba728f" }, "downloads": -1, "filename": "postgres_db_diff-0.9.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "d5c49768063ae5e4bd609bc05ff68c49", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 7278, "upload_time": "2017-12-27T16:32:42", "url": "https://files.pythonhosted.org/packages/23/ea/91e8d7b2bee6fa8be8f2386c43c93c30c615d02d0b07db045f55673608f6/postgres_db_diff-0.9.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "470b507270895d9025ff1ec250ea5771", "sha256": "5fbec7e4daad9b9de7a25cae3f81ffe04e2135e2cd8848c231fc04ae9e43302c" }, "downloads": -1, "filename": "postgres-db-diff-0.9.1.tar.gz", "has_sig": false, "md5_digest": "470b507270895d9025ff1ec250ea5771", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5838, "upload_time": "2017-12-27T16:32:44", "url": "https://files.pythonhosted.org/packages/99/6f/ab96b4cc516e893ff84a879f9cc568feaf50885677a20835f8dc91d78b0b/postgres-db-diff-0.9.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "d5c49768063ae5e4bd609bc05ff68c49", "sha256": "0ac4f248e2059e2d25add34a754e787ab06fb687b79c2b6c12b8fe44f3ba728f" }, "downloads": -1, "filename": "postgres_db_diff-0.9.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "d5c49768063ae5e4bd609bc05ff68c49", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 7278, "upload_time": "2017-12-27T16:32:42", "url": "https://files.pythonhosted.org/packages/23/ea/91e8d7b2bee6fa8be8f2386c43c93c30c615d02d0b07db045f55673608f6/postgres_db_diff-0.9.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "470b507270895d9025ff1ec250ea5771", "sha256": "5fbec7e4daad9b9de7a25cae3f81ffe04e2135e2cd8848c231fc04ae9e43302c" }, "downloads": -1, "filename": "postgres-db-diff-0.9.1.tar.gz", "has_sig": false, "md5_digest": "470b507270895d9025ff1ec250ea5771", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5838, "upload_time": "2017-12-27T16:32:44", "url": "https://files.pythonhosted.org/packages/99/6f/ab96b4cc516e893ff84a879f9cc568feaf50885677a20835f8dc91d78b0b/postgres-db-diff-0.9.1.tar.gz" } ] }