{"id":13567151,"url":"https://github.com/samuller/pgmerge","last_synced_at":"2025-04-04T01:31:08.562Z","repository":{"id":46672796,"uuid":"118240388","full_name":"samuller/pgmerge","owner":"samuller","description":"A utility to help with exporting, importing and merging CSV data into a Postgresql database.","archived":false,"fork":false,"pushed_at":"2023-10-29T07:11:08.000Z","size":438,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-04-09T05:36:09.280Z","etag":null,"topics":["export","import","merge","postgres","postgresql"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/samuller.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-01-20T12:21:20.000Z","updated_at":"2024-05-16T21:38:43.673Z","dependencies_parsed_at":"2022-09-02T06:43:52.260Z","dependency_job_id":"f475dab0-ea2e-45be-a491-4e65088e58bd","html_url":"https://github.com/samuller/pgmerge","commit_stats":{"total_commits":541,"total_committers":1,"mean_commits":541.0,"dds":0.0,"last_synced_commit":"07179e1b972a368d7dd7b6832e181599461a7d0c"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samuller%2Fpgmerge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samuller%2Fpgmerge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samuller%2Fpgmerge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samuller%2Fpgmerge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/samuller","download_url":"https://codeload.github.com/samuller/pgmerge/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247107816,"owners_count":20884793,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["export","import","merge","postgres","postgresql"],"created_at":"2024-08-01T13:02:24.889Z","updated_at":"2025-04-04T01:31:06.043Z","avatar_url":"https://github.com/samuller.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# pgmerge - a PostgreSQL data import and merge utility\n\n[![Build Status](https://github.com/samuller/pgmerge/actions/workflows/tests.yml/badge.svg)](https://github.com/samuller/pgmerge/actions)\n[![PyPI Version](https://badge.fury.io/py/pgmerge.svg)](https://badge.fury.io/py/pgmerge)\n[![Code Coverage](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/samuller/3c84321138784d39b31a02d7fe93b31d/raw/badge-coverage.json)](https://github.com/samuller/pgmerge/actions)\n[![Checked with mypy](https://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/)\n[![Formatted with black](https://img.shields.io/badge/code%20style-black-black)](https://black.readthedocs.io/en/stable/)\n\nThis utility's main purpose is to manage a set of CSV files that correspond with tables in a PostgreSQL database:\n\n* Each of these CSV file's data can then be *merged* into their corresponding table (see section below).\n* The database schema is analysed to determine dependencies among tables (due to foreign keys), and CSV files are then imported in the correct order such that the data/tables that they might depend on have been imported first.\n* `pgmerge` can then also export data in the same format expected for import.\n\nThese features allow you to move data between databases with the same schema to keep them up to date and in sync, although it does not cover handling deleted data.\n\n### Import merging\n\nMerging CSVs into a table means that the following process will occur (also called an *upsert* operation):\n\n* Rows whose primary key don't yet exist in the table will be imported.\n* When the primary key already exists, row values will be updated.\n* Rows that are missing or unchanged will be ignored.\n\n## CLI arguments\n\n    $ pgmerge --help\n    Usage: pgmerge [OPTIONS] COMMAND [ARGS]...\n\n    Merges data in CSV files into a Postgresql database.\n\n    Options:\n    --version  Show the version and exit.\n    --help     Show this message and exit.\n\n    Commands:\n    export  Export each table to a CSV file.\n    import  Import/merge each CSV file into a table.\n    inspect  Inspect database schema in various ways.\n\n### Import\n\n    $ pgmerge import --help\n    Usage: pgmerge import [OPTIONS] DIRECTORY [TABLES]...\n\n    Import/merge each CSV file into a table.\n\n    All CSV files need the same name as their matching table and have to be located\n    in the given directory. If one or more tables are specified then only they will\n    be used, otherwise all tables found will be selected.\n\n    Options:\n    -d, --dbname TEXT               Database name to connect to.  [required]\n    -h, --host TEXT                 Database server host or socket directory.\n                                    [default: localhost]\n    -p, --port TEXT                 Database server port.  [default: 5432]\n    -U, --username TEXT             Database user name.  [default: postgres]\n    -s, --schema TEXT               Database schema to use.  [default: public]\n    -w, --no-password               Never prompt for password (e.g. peer\n                                    authentication).\n    -W, --password TEXT             Database password (default is to prompt for\n                                    password or read config).\n    -L, --uri TEXT                  Connection URI can be used instead of specifying\n                                    parameters separately (also sets --no-password).\n    -f, --ignore-cycles             Don't stop import when cycles are detected in\n                                    schema (will still fail if there are cycles in\n                                    data)\n    -F, --disable-foreign-keys      Disable foreign key constraint checking during\n                                    import (necessary if you have cycles, but requires\n                                    superuser rights).\n    -c, --config PATH               Config file for customizing how tables are\n                                    imported/exported.\n    -i, --include-dependent-tables  When selecting specific tables, also include all\n                                    tables on which they depend due to foreign key\n                                    constraints.\n    --help                          Show this message and exit.\n\n## Installation\n\n\u003e WARNING: the reliability of this utility is not guaranteed and loss or corruption of data is always a possibility.\n\n### Install from PyPI\n\nWith `Python 3` installed on your system, you can run:\n\n    pip install pgmerge\n\nTo test that installation worked, run:\n\n    pgmerge --help\n\nand you can uninstall at any time with:\n\n    pip uninstall pgmerge\n\n### Install from Github\n\nTo install the newest code directly from Github:\n\n    pip install git+https://github.com/samuller/pgmerge\n\n### Issues\n\nIf you have trouble installing and you're running a Debian-based Linux that uses `Python 2` as its system default, then you might need to run:\n\n    sudo apt install libpq-dev python3-pip python3-setuptools\n    sudo -H pip3 install pgmerge\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamuller%2Fpgmerge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsamuller%2Fpgmerge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamuller%2Fpgmerge/lists"}