{"id":18676593,"url":"https://github.com/hitchdev/hitchbuildpg","last_synced_at":"2025-11-07T06:30:35.546Z","repository":{"id":57437382,"uuid":"132617263","full_name":"hitchdev/hitchbuildpg","owner":"hitchdev","description":"Tool to build postgres databases for development and testing.","archived":false,"fork":false,"pushed_at":"2020-07-27T15:42:13.000Z","size":39,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-27T23:26:15.923Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hitchdev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-05-08T14:00:31.000Z","updated_at":"2020-11-22T10:14:17.000Z","dependencies_parsed_at":"2022-09-11T03:23:03.606Z","dependency_job_id":null,"html_url":"https://github.com/hitchdev/hitchbuildpg","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hitchdev%2Fhitchbuildpg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hitchdev%2Fhitchbuildpg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hitchdev%2Fhitchbuildpg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hitchdev%2Fhitchbuildpg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hitchdev","download_url":"https://codeload.github.com/hitchdev/hitchbuildpg/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239520734,"owners_count":19652747,"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":[],"created_at":"2024-11-07T09:29:56.485Z","updated_at":"2025-11-07T06:30:35.501Z","avatar_url":"https://github.com/hitchdev.png","language":"Python","readme":"# HitchBuildPg\n\nA small, self contained python library for building postgres database locally that, on first run will:\n\n* Downloads and compiles a specified version of postgres.\n\n* Builds a database from a series of SQL commands and by restoring a database dump file.\n\n* Takes a snapshot of the newly built database files by taking a copy of the folder.\n\nOn subsequent builds, it will skip the long, expensive steps of downloading, compiling postgres\nand restoring a database from a .sql file and just overwrite the data files.\n\n\n```python\nimport hitchbuildpg\n\npostgres_version = \"10.10\"\n    \npgapp_dir = \"{}/postgres-{}\".format(share, postgres_version)\n\npgapp = hitchbuildpg.PostgresApp(pgapp_dir, postgres_version)\n\nclass DataBuild(hitchbuildpg.DataBuild):\n    def run(self):\n        self.run_sql_as_root(\"create user myuser with password 'mypassword';\")\n        self.run_sql_as_root(\"create database mydb with owner myuser;\")\n        self.load_database_dump(\n            database=\"mydb\",\n            username=\"myuser\",\n            password=\"mypassword\",\n            filename=\"dump.sql\"\n        )\n\npgdata = hitchbuildpg.PostgresDatafiles(\n    \"./myappdata\",\n    pgapp,\n    DataBuild(),\n)\n\npgdata.ensure_built()\n\ndb_service = pgdata.server()\ndb_service.start()\n\npsql = db_service.psql(\n    \"-U\", \"myuser\", \"-p\", \"15432\", \"-d\", \"mydb\",\n).with_env(PG_PASSWORD=\"mypassword\")\n\npsql(\"-c\", \"select name from cities where location = 'GB';\").run()\n\n# Prints output of SQL statement\n    \npsql(\"-c\", \"delete from cities where location = 'GB';\").run()\n      \ndb_service.stop()\n```\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhitchdev%2Fhitchbuildpg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhitchdev%2Fhitchbuildpg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhitchdev%2Fhitchbuildpg/lists"}