{"id":17783544,"url":"https://github.com/skalt/postgres_sample_dbs","last_synced_at":"2026-01-20T21:33:41.690Z","repository":{"id":139646271,"uuid":"489345350","full_name":"SKalt/postgres_sample_dbs","owner":"SKalt","description":"A collection of postgres sample dbs","archived":false,"fork":false,"pushed_at":"2023-06-04T15:48:04.000Z","size":141593,"stargazers_count":1,"open_issues_count":11,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-07T12:31:01.297Z","etag":null,"topics":["examples","postgres","postgresql","sql"],"latest_commit_sha":null,"homepage":"","language":"PLpgSQL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SKalt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2022-05-06T12:26:17.000Z","updated_at":"2023-08-08T16:41:24.000Z","dependencies_parsed_at":null,"dependency_job_id":"d9f410f8-159f-4e30-80d5-75cfea6a6b31","html_url":"https://github.com/SKalt/postgres_sample_dbs","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/SKalt/postgres_sample_dbs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SKalt%2Fpostgres_sample_dbs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SKalt%2Fpostgres_sample_dbs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SKalt%2Fpostgres_sample_dbs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SKalt%2Fpostgres_sample_dbs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SKalt","download_url":"https://codeload.github.com/SKalt/postgres_sample_dbs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SKalt%2Fpostgres_sample_dbs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28614614,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-20T18:56:40.769Z","status":"ssl_error","status_checked_at":"2026-01-20T18:54:26.653Z","response_time":117,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["examples","postgres","postgresql","sql"],"created_at":"2024-10-27T07:43:10.015Z","updated_at":"2026-01-20T21:33:41.673Z","avatar_url":"https://github.com/SKalt.png","language":"PLpgSQL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Postgres Sample Dbs\n\nA collection of postgres sample dbs in a standardized format.\n\n## Licensing\n\nEach of the sample databases contains its own license file(s).\nEach database dump in the releases include the database's license in a comment at the start of the database dump.\n\nThe code to extract, transform, and load the sample databases is licensed as MIT in [./LICENSE.md](./LICENSE.md)\n\n## Directory structure\n\nEach checked-in sample db in the `./sample_dbs` directory\n\n```\n${db_name}\n├── sql/*.{ddl,dml}.sql{,.gz}\n├── README*   # optional\n└── LICENSE*\n```\n\nNote that files\n\n- some files \u003e5MB are gzipped (the files matching `dml/*.sql.gz`).\n\n## Usage\n\n### download\n\n#### from releases (preferred)\n\nDownload one of the `all_*_dumps.tar.gz`s from [the latest release](https://github.com/SKalt/postgres_sample_dbs/releases/latest), unpack it, and pipe any of the database dumps directly into `psql`.\n\n### restore\n\n\u003cdetails open\u003e\u003csummary\u003eshell\u003c/summary\u003e\n\n```sh\n#!/usr/bin/env sh\nset -eu\npass() { return 0; }\nload_file() {\n  case \"$1\" in\n    *.gz) gunzip -c \"$1\" | psql;;\n    *.sql) psql -f \"$1\" ;;\n  esac\n}\nrestore_sample_db() {\n  path_to_sample_db=$1\n  schema_only=${2:-false}\n\n  for f in \"$path_to_sample\"/sql/*.sql*; do\n    case \"$f\" in\n    *.ddl.*) load_file \"$f\";;\n    *.dml.*)\n      if [ \"$schema_only\" = \"true\" ]; then pass\n      else load_file \"$f\"\n      fi\n      ;;\n    esac\n  fi\n}\n\n# if your current working directory was in this repo's root\n# and you have a running postgres db\nrestore_sample_db ./sample_dbs/sakila/sql\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003epython\u003c/summary\u003e\n\n```py\n#!/usr/bin/env python3\n\"\"\"\nUSAGE: load.py path/to/sql_dir\n\"\"\"\nimport gzip\nimport logging\nimport os\nimport subprocess\nimport sys\nassert sys.version \u003e= (3, 7)\n\nfrom argparse import ArgumentParser\nfrom pathlib import Path\n\ncli = ArgumentParser()\ncli.add_arg(\"--dry-run\", action=\"store_true\", help=\"print what would be run\")\ncli.add_arg(\"--schema-only\", action=\"store_true\", help=\"filter out dml\")\ncli.add_arg(\"path\", type=Path)\n\ndef main(path: str, schema_only: bool = False, dry_run: bool = False) -\u003e None:\n    sql_dir = Path(path)\n    assert sql_dir.exists(), f\"{sql_dir} does not exist\"\n    assert sql_dir.is_dir(), f\"{sql_dir} is not a directory\"\n    for file in sql_dir.iterdir():\n        if schema_only and '.dml.' in file.name:\n            continue\n        if dry_run:\n            logging.info(f\"would restore {file}\")\n            continue\n        logging.info(f\"restoring {file}\")\n        with gzip.open(file) if file.name.endswith(\".gz\") else file as f:\n            data = f.read()\n        subprocess.run([\"psql\"], input=data, check=True)\n\n\nif __name__ == \"__main__\":\n    logging.basicConfig(level=logging.INFO)\n    args = cli.parse_args()\n    main(args.path, args.schema_only, args.dry_run)\n```\n\n\u003c/details\u003e\n\n\u003c!-- TODO: go, rust, perl --\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskalt%2Fpostgres_sample_dbs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fskalt%2Fpostgres_sample_dbs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskalt%2Fpostgres_sample_dbs/lists"}